diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-05-24 23:57:43 -0400 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-05-24 23:57:43 -0400 |
commit | 779ccf8a0e6a8bf7bb362c30dac4a340599ab113 (patch) | |
tree | 6ba707f5fca16144290128c4a3eb386ca6a6968c /activerecord/lib/active_record/connection_adapters/connection_specification.rb | |
parent | 5167b8f7ffa66c8772c455916b8418844e3b4674 (diff) | |
download | rails-779ccf8a0e6a8bf7bb362c30dac4a340599ab113.tar.gz rails-779ccf8a0e6a8bf7bb362c30dac4a340599ab113.tar.bz2 rails-779ccf8a0e6a8bf7bb362c30dac4a340599ab113.zip |
Remove `name` from `establish_connection`
Instead of passing a separete name variable, we can make the resolver
merge a name on the config, and use that before creating the Specification.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/connection_specification.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index 7636de067c..0f4bd1c84a 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -164,7 +164,7 @@ module ActiveRecord # spec.config # # => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" } # - def spec(config, name = nil) + def spec(config) spec = resolve(config).symbolize_keys raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter) @@ -184,13 +184,7 @@ module ActiveRecord raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter" end - name ||= - if config.is_a?(Symbol) - config.to_s - else - "primary" - end - ConnectionSpecification.new(name, spec, adapter_method) + ConnectionSpecification.new(spec.delete(:name) || "primary", spec, adapter_method) end private @@ -235,7 +229,7 @@ module ActiveRecord # def resolve_symbol_connection(spec) if config = configurations[spec.to_s] - resolve_connection(config) + resolve_connection(config).merge("name" => spec.to_s) else raise(AdapterNotSpecified, "'#{spec}' database is not configured. Available: #{configurations.keys.inspect}") end |