Class: ActiveRecordPartitioning::ConnectionPools
- Inherits:
-
Object
- Object
- ActiveRecordPartitioning::ConnectionPools
- Includes:
- Enumerable
- 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.
- #keys ⇒ Object
- #merge!(pools) ⇒ Object
- #size ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(key_name, store = {}) ⇒ ConnectionPools
Returns a new instance of ConnectionPools.
10 11 12 13 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 10 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.
8 9 10 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 8 def key_name @key_name end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
8 9 10 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 8 def store @store end |
Instance Method Details
#[](klass_name) ⇒ Object
21 22 23 24 25 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 21 def [](klass_name) config = ActiveRecordPartitioning.current_connection_pool_config raise NoActiveConnectionPoolError if config.nil? @store[connection_pool_key(config)] end |
#[]=(klass_name, pool) ⇒ Object
27 28 29 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 27 def []=(klass_name, pool) @store[connection_pool_key(pool.spec.config)] = pool end |
#delete_if(&block) ⇒ Object
31 32 33 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 31 def delete_if(&block) @store.delete_if(&block) end |
#each(&block) ⇒ Object
39 40 41 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 39 def each(&block) @store.each(&block) end |
#each_value(&block) ⇒ Object
35 36 37 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 35 def each_value(&block) @store.each_value(&block) end |
#keys ⇒ Object
47 48 49 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 47 def keys @store.keys end |
#merge!(pools) ⇒ Object
15 16 17 18 19 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 15 def merge!(pools) pools.each do |klass_name, pool| self[klass_name] = pool end end |
#size ⇒ Object
51 52 53 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 51 def size @store.size end |
#values ⇒ Object
43 44 45 |
# File 'lib/activerecord_partitioning/connection_pools.rb', line 43 def values @store.values end |