module ActiveRecord::Bogacs::Validator::PoolAdaptor
Public Class Methods
adapt!(pool)
click to toggle source
# File lib/active_record/bogacs/validator.rb, line 130 def self.adapt!(pool) unless pool.class.include?(PoolAdaptor) pool.class.send :include, PoolAdaptor end return if pool.respond_to?(:thread_cached_conns) if pool.instance_variable_get :@reserved_connections class << pool attr_reader :reserved_connections alias_method :thread_cached_conns, :reserved_connections end elsif pool.instance_variable_get :@thread_cached_conns class << pool attr_reader :thread_cached_conns end else raise NotImplementedError, "could not adapt pool: #{pool}" end end
Public Instance Methods
cached_conn_owner_id(conn)
click to toggle source
# File lib/active_record/bogacs/validator.rb, line 151 def cached_conn_owner_id(conn) thread_cached_conns.keys.each do |owner_id| if thread_cached_conns[ owner_id ] == conn return owner_id end end nil end
release_without_owner(conn)
click to toggle source
# File lib/active_record/bogacs/validator.rb, line 165 def release_without_owner(conn) if owner_id = cached_conn_owner_id(conn) thread_cached_conns.delete owner_id return true end end
remove_without_owner(conn)
click to toggle source
# File lib/active_record/bogacs/validator.rb, line 160 def remove_without_owner(conn) remove conn # release(conn, nil) owner.object_id should do fine release_without_owner conn end