aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2016-05-04 12:00:21 -0500
committerArthur Neves <arthurnn@gmail.com>2016-05-05 15:29:11 -0500
commitc1bc0d83def740648fdbed05fcc3283dcef1f07d (patch)
tree41f084e81beb748298ae4407832368a81a8aad58 /activerecord
parent314cf0398c6b8a76ee9fe86ba8c2926d3b54ab28 (diff)
downloadrails-c1bc0d83def740648fdbed05fcc3283dcef1f07d.tar.gz
rails-c1bc0d83def740648fdbed05fcc3283dcef1f07d.tar.bz2
rails-c1bc0d83def740648fdbed05fcc3283dcef1f07d.zip
Better specification_id method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_handling.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index 8246c12ea8..543992dcbf 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -49,6 +49,7 @@ module ActiveRecord
spec ||= DEFAULT_ENV.call.to_sym
resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new configurations
+ # TODO: uses name on establish_connection, for backwards compatibility
spec = resolver.spec(spec, self == Base ? "primary" : name)
self.specification_id = spec.id
@@ -94,17 +95,13 @@ module ActiveRecord
@specification_id = value
end
- def specification_id(fallback = true)
- return @specification_id if defined?(@specification_id)
- find_parent_spec_id(self) if fallback
- end
-
- def find_parent_spec_id(klass)
- return "primary" if klass == Base
- if id = klass.specification_id(false)
- return id
+ # Return the specification id from this class otherwise look it up
+ # in the parent.
+ def specification_id
+ unless defined?(@specification_id)
+ @specification_id = self == Base ? "primary" : superclass.specification_id
end
- find_parent_spec_id(klass.superclass)
+ @specification_id
end
def connection_id