Class: SlavePools
- Inherits:
-
Object
- Object
- SlavePools
- Defined in:
- lib/slave_pools.rb
Overview
wrapper class to make the calls more succinct
Class Method Summary collapse
- .active? ⇒ Boolean
- .current ⇒ Object
- .next_slave! ⇒ Object
- .setup! ⇒ Object
- .with_master ⇒ Object
- .with_pool(pool_name = 'default') ⇒ Object
Class Method Details
.active? ⇒ Boolean
16 17 18 |
# File 'lib/slave_pools.rb', line 16 def self.active? ActiveRecord::Base.respond_to?('connection_proxy') end |
.current ⇒ Object
40 41 42 |
# File 'lib/slave_pools.rb', line 40 def self.current ActiveRecord::Base.connection_proxy.current if active? end |
.next_slave! ⇒ Object
20 21 22 |
# File 'lib/slave_pools.rb', line 20 def self.next_slave! ActiveRecord::Base.connection_proxy.next_slave! if active? end |
.setup! ⇒ Object
12 13 14 |
# File 'lib/slave_pools.rb', line 12 def self.setup! SlavePoolsModule::ConnectionProxy.setup! end |
.with_master ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/slave_pools.rb', line 32 def self.with_master if active? ActiveRecord::Base.connection_proxy.with_master { yield } else yield end end |
.with_pool(pool_name = 'default') ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/slave_pools.rb', line 24 def self.with_pool(pool_name = 'default') if active? ActiveRecord::Base.connection_proxy.with_pool(pool_name) { yield } else yield end end |