aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-11-29 11:48:55 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-11-29 11:48:55 -0800
commitf73f53455a01a93bd90cb8c0cee1a7c54afdb301 (patch)
treee146be7d30d3e70fc946a64d1c81fceb9cfc073e /activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
parent2169603385a447256d713873be6b2fbb6e2591fa (diff)
downloadrails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.tar.gz
rails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.tar.bz2
rails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.zip
respond_to? information of AR is not the responsibility of the spec
resolver.
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.rb16
1 files changed, 9 insertions, 7 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 f2e7f88011..ca9fb11e95 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -11,9 +11,8 @@ module ActiveRecord
class Resolver # :nodoc:
attr_reader :config, :klass, :configurations
- def initialize(config, klass, configurations)
+ def initialize(config, configurations)
@config = config
- @klass = klass
@configurations = configurations
end
@@ -52,9 +51,6 @@ module ActiveRecord
end
adapter_method = "#{spec[:adapter]}_connection"
- unless klass.respond_to?(adapter_method)
- raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter"
- end
ConnectionSpecification.new(spec, adapter_method)
end
@@ -127,9 +123,15 @@ module ActiveRecord
# The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError
# may be returned on an error.
def self.establish_connection(spec = ENV["DATABASE_URL"])
- resolver = ConnectionSpecification::Resolver.new spec, self, configurations
+ resolver = ConnectionSpecification::Resolver.new spec, configurations
+ spec = resolver.spec
+
+ unless respond_to?(spec.adapter_method)
+ raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter"
+ end
+
remove_connection
- connection_handler.establish_connection name, resolver.spec
+ connection_handler.establish_connection name, spec
end
class << self