0
@@ -15,12 +15,16 @@ module ActiveRecord
0
@@verification_timeout = 0
0
# The class -> connection pool map
0
- @@
defined_connections = {}
0
+ @@
connection_pools = {}
0
# for internal use only
0
- @@defined_connections.inject([]) {|arr,kv| arr << kv.last.active_connection}.compact.uniq
0
+ @@connection_pools.inject({}) do |hash,kv|
0
+ hash[kv.first] = kv.last.active_connection
0
+ hash.delete(kv.first) unless hash[kv.first]
0
# Returns the connection currently associated with the class. This can
0
@@ -32,21 +36,27 @@ module ActiveRecord
0
# Clears the cache which maps classes to connections.
0
def clear_active_connections!
0
- clear_cache!(@@defined_connections) do |name, pool|
0
+ clear_cache!(@@connection_pools) do |name, pool|
0
+ pool.clear_active_connections!
0
# Clears the cache which maps classes
0
def clear_reloadable_connections!
0
- clear_cache!(@@
defined_connections) do |name, pool|
0
+ clear_cache!(@@
connection_pools) do |name, pool|
0
pool.clear_reloadable_connections!
0
+ def clear_all_connections!
0
+ clear_cache!(@@connection_pools) do |name, pool|
0
# Verify active connections.
0
def verify_active_connections! #:nodoc:
0
- @@
defined_connections.each_value {|pool| pool.verify_active_connections!}
0
+ @@
connection_pools.each_value {|pool| pool.verify_active_connections!}
0
@@ -97,7 +107,7 @@ module ActiveRecord
0
raise AdapterNotSpecified unless defined? RAILS_ENV
0
establish_connection(RAILS_ENV)
0
when ConnectionSpecification
0
- @@
defined_connections[name] = ConnectionAdapters::ConnectionPool.new(spec)
0
+ @@
connection_pools[name] = ConnectionAdapters::ConnectionPool.new(spec)
0
if configuration = configurations[spec.to_s]
0
establish_connection(configuration)
0
@@ -140,7 +150,7 @@ module ActiveRecord
0
def self.retrieve_connection_pool
0
- pool = @@
defined_connections[name]
0
+ pool = @@
connection_pools[name]
0
return nil if ActiveRecord::Base == self
0
superclass.retrieve_connection_pool
0
@@ -156,8 +166,8 @@ module ActiveRecord
0
# can be used as an argument for establish_connection, for easily
0
# re-establishing the connection.
0
def self.remove_connection(klass=self)
0
- pool = @@defined_connections[klass.name]
0
- @@defined_connections.delete_if { |key, value| value == pool }
0
+ pool = @@connection_pools[klass.name]
0
+ @@connection_pools.delete_if { |key, value| value == pool }
0
pool.disconnect! if pool
0
pool.spec.config if pool