diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-05-07 12:25:37 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-05-24 22:03:00 -0400 |
commit | 5167b8f7ffa66c8772c455916b8418844e3b4674 (patch) | |
tree | 75443d0cf8311d52e4eb52d39ced3038b23d1f1d /activerecord/lib/active_record/connection_handling.rb | |
parent | bf219714dce494f5b69cb7dd9b8c43a68a4988da (diff) | |
download | rails-5167b8f7ffa66c8772c455916b8418844e3b4674.tar.gz rails-5167b8f7ffa66c8772c455916b8418844e3b4674.tar.bz2 rails-5167b8f7ffa66c8772c455916b8418844e3b4674.zip |
Move establish_connection to handler
Diffstat (limited to 'activerecord/lib/active_record/connection_handling.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_handling.rb | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index f932deb18d..b3fd837abe 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -44,21 +44,13 @@ module ActiveRecord # # The exceptions AdapterNotSpecified, AdapterNotFound and +ArgumentError+ # may be returned on an error. - def establish_connection(spec = nil) + def establish_connection(config = nil) raise "Anonymous class is not allowed." unless name - 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) - - unless respond_to?(spec.adapter_method) - raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter" - end - - remove_connection(spec.name) - self.connection_specification_name = spec.name - connection_handler.establish_connection spec + config ||= DEFAULT_ENV.call.to_sym + spec_name = self == Base ? "primary" : name + self.connection_specification_name = spec_name + connection_handler.establish_connection(config, name: spec_name) end class MergeAndResolveDefaultUrlConfig # :nodoc: |