Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/master_slave_adapter.rb
Class Method Summary collapse
- .master_slave_connection(config) ⇒ Object
- .mysql_master_slave_connection(config) ⇒ Object
- .on_commit(&blk) ⇒ Object
- .on_rollback(&blk) ⇒ Object
- .with_consistency(clock, &blk) ⇒ Object
- .with_master(&blk) ⇒ Object
- .with_slave(&blk) ⇒ Object
Class Method Details
.master_slave_connection(config) ⇒ Object
39 40 41 42 43 |
# File 'lib/master_slave_adapter.rb', line 39 def master_slave_connection(config) config = massage(config) load_adapter(config.fetch(:connection_adapter)) ConnectionAdapters::MasterSlaveAdapter.new(config, logger) end |
.mysql_master_slave_connection(config) ⇒ Object
45 46 47 |
# File 'lib/master_slave_adapter.rb', line 45 def mysql_master_slave_connection(config) master_slave_connection(config) end |
.on_commit(&blk) ⇒ Object
31 32 33 |
# File 'lib/master_slave_adapter.rb', line 31 def on_commit(&blk) connection.on_commit(&blk) if connection.respond_to? :on_commit end |
.on_rollback(&blk) ⇒ Object
35 36 37 |
# File 'lib/master_slave_adapter.rb', line 35 def on_rollback(&blk) connection.on_rollback(&blk) if connection.respond_to? :on_rollback end |
.with_consistency(clock, &blk) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/master_slave_adapter.rb', line 6 def with_consistency(clock, &blk) if connection.respond_to? :with_consistency connection.with_consistency(clock, &blk) else yield nil end end |
.with_master(&blk) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/master_slave_adapter.rb', line 15 def with_master(&blk) if connection.respond_to? :with_master connection.with_master(&blk) else yield end end |
.with_slave(&blk) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/master_slave_adapter.rb', line 23 def with_slave(&blk) if connection.respond_to? :with_slave connection.with_slave(&blk) else yield end end |