Class: ActiveRecord::ConnectionAdapters::ConnectionPool::UsedPoolSet
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb |
Overview
The pools that an execution context has used.
Class Method Summary
Instance Method Summary
Constructor Details
.new(query_caches = ObjectSpace::WeakKeyMap.new) ⇒ UsedPoolSet
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 138
def initialize(query_caches = ObjectSpace::WeakKeyMap.new) @query_caches = query_caches # The above WeakKeyMap can't be iterated, so we need a separate (also # weak) list of its keys. @pools = ActiveSupport::WeakSet.new end
Instance Method Details
#add(pool)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 150
def add(pool) return if @pools.include?(pool) @pools << pool if (cache = @query_caches[pool]) pool.prepare_query_cache(cache) end end
#each_pool(&block)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 163
def each_pool(&block) @pools.each(&block) end
#include?(pool) ⇒ Boolean
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 159
def include?(pool) @pools.include?(pool) end
#initialize_copy(other)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 167
def initialize_copy(other) super @pools = @pools.dup end
#query_cache_for(pool)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 145
def query_cache_for(pool) add(pool) @query_caches[pool] ||= pool.build_query_cache end
#without_pools
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 172
def without_pools self.class.new(@query_caches) end