diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 11:50:43 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 11:50:43 -0800 |
commit | d65e3b481e72e8c76818a94353e9ac315c7c0272 (patch) | |
tree | 86b9cbbb97f342d9e5efa11128f3661fb5578739 /activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | |
parent | 1a15fda02159487371a0cb4c36311345dec7b46b (diff) | |
download | rails-d65e3b481e72e8c76818a94353e9ac315c7c0272.tar.gz rails-d65e3b481e72e8c76818a94353e9ac315c7c0272.tar.bz2 rails-d65e3b481e72e8c76818a94353e9ac315c7c0272.zip |
ARel only requires the connection from the AR class. Simply return the AR class rather than jump through hoops and store ivars
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 3716937689..5a6d13e64b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -50,34 +50,34 @@ module ActiveRecord # may be returned on an error. def self.establish_connection(spec = nil) case spec - when nil - raise AdapterNotSpecified unless defined?(Rails.env) - establish_connection(Rails.env) - when ConnectionSpecification - self.connection_handler.establish_connection(name, spec) - when Symbol, String - if configuration = configurations[spec.to_s] - establish_connection(configuration) - else - raise AdapterNotSpecified, "#{spec} database is not configured" - end + when nil + raise AdapterNotSpecified unless defined?(Rails.env) + establish_connection(Rails.env) + when ConnectionSpecification + self.connection_handler.establish_connection(name, spec) + when Symbol, String + if configuration = configurations[spec.to_s] + establish_connection(configuration) else - spec = spec.symbolize_keys - unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end + raise AdapterNotSpecified, "#{spec} database is not configured" + end + else + spec = spec.symbolize_keys + unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end - begin - require "active_record/connection_adapters/#{spec[:adapter]}_adapter" - rescue LoadError => e - raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{e})" - end + begin + require "active_record/connection_adapters/#{spec[:adapter]}_adapter" + rescue LoadError => e + raise "Please install the #{spec[:adapter]} adapter: `gem install activerecord-#{spec[:adapter]}-adapter` (#{e})" + end - adapter_method = "#{spec[:adapter]}_connection" - unless respond_to?(adapter_method) - raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" - end + adapter_method = "#{spec[:adapter]}_connection" + unless respond_to?(adapter_method) + raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" + end - remove_connection - establish_connection(ConnectionSpecification.new(spec, adapter_method)) + remove_connection + establish_connection(ConnectionSpecification.new(spec, adapter_method)) end end |