Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/master_slave_adapter.rb,
lib/active_record/connection_adapters/mysql_master_slave_adapter.rb,
lib/active_record/connection_adapters/mysql2_master_slave_adapter.rb
Class Method Summary collapse
- .master_slave_connection(config) ⇒ Object
- .mysql2_master_slave_connection(config) ⇒ Object
- .mysql_master_slave_connection(config) ⇒ Object
- .with_consistency(clock, &blk) ⇒ Object
- .with_master(&blk) ⇒ Object
- .with_slave(&blk) ⇒ Object
Class Method Details
.master_slave_connection(config) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/active_record/connection_adapters/master_slave_adapter.rb', line 35 def master_slave_connection(config) config = massage(config) adapter = config.fetch(:connection_adapter) name = "#{adapter}_master_slave" load_adapter(name) send(:"#{name}_connection", config) end |
.mysql2_master_slave_connection(config) ⇒ Object
9 10 11 |
# File 'lib/active_record/connection_adapters/mysql2_master_slave_adapter.rb', line 9 def self.mysql2_master_slave_connection(config) ConnectionAdapters::Mysql2MasterSlaveAdapter.new(config, logger) end |
.mysql_master_slave_connection(config) ⇒ Object
8 9 10 |
# File 'lib/active_record/connection_adapters/mysql_master_slave_adapter.rb', line 8 def self.mysql_master_slave_connection(config) ConnectionAdapters::MysqlMasterSlaveAdapter.new(config, logger) end |
.with_consistency(clock, &blk) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/active_record/connection_adapters/master_slave_adapter.rb', line 10 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
19 20 21 22 23 24 25 |
# File 'lib/active_record/connection_adapters/master_slave_adapter.rb', line 19 def with_master(&blk) if connection.respond_to? :with_master connection.with_master(&blk) else yield end end |
.with_slave(&blk) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/active_record/connection_adapters/master_slave_adapter.rb', line 27 def with_slave(&blk) if connection.respond_to? :with_slave connection.with_slave(&blk) else yield end end |