Class: ActiveRecordPartitioning::ConnectionPools
- Inherits:
-
Object
- Object
- ActiveRecordPartitioning::ConnectionPools
- Defined in:
- lib/activerecord_partitioning/connection_pools.rb
Instance Attribute Summary collapse
-
#key_name ⇒ Object
readonly
Returns the value of attribute key_name.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #[](klass_name) ⇒ Object
- #[]=(klass_name, pool) ⇒ Object
- #delete_if(&block) ⇒ Object
- #each(&block) ⇒ Object
- #each_value(&block) ⇒ Object
-
#initialize(key_name, store = {}) ⇒ ConnectionPools
constructor
A new instance of ConnectionPools.
- #merge!(pools) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(key_name, store = {}) ⇒ ConnectionPools
Returns a new instance of ConnectionPools.
8 9 10 11 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 8 def initialize(key_name, store={}) @key_name = key_name @store = store end |
Instance Attribute Details
#key_name ⇒ Object (readonly)
Returns the value of attribute key_name.
6 7 8 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 6 def key_name @key_name end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
6 7 8 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 6 def store @store end |
Instance Method Details
#[](klass_name) ⇒ Object
19 20 21 22 23 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 19 def [](klass_name) config = ActiveRecordPartitioning.current_connection_pool_config raise NoActiveConnectionPoolError if config.nil? @store[connection_pool_key(config)] end |
#[]=(klass_name, pool) ⇒ Object
25 26 27 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 25 def []=(klass_name, pool) @store[connection_pool_key(pool.spec.config)] = pool end |
#delete_if(&block) ⇒ Object
29 30 31 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 29 def delete_if(&block) @store.delete_if(&block) end |
#each(&block) ⇒ Object
37 38 39 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 37 def each(&block) @store.each(&block) end |
#each_value(&block) ⇒ Object
33 34 35 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 33 def each_value(&block) @store.each_value(&block) end |
#merge!(pools) ⇒ Object
13 14 15 16 17 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 13 def merge!(pools) pools.each do |klass_name, pool| self[klass_name] = pool end end |
#size ⇒ Object
41 42 43 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 41 def size @store.size end |