Module: DbCharmer::MultiDbProxy::MasterSlaveClassMethods

Defined in:
lib/db_charmer/multi_db_proxy.rb

Instance Method Summary collapse

Instance Method Details

#on_master(proxy_target = nil, &block) ⇒ Object



45
46
47
# File 'lib/db_charmer/multi_db_proxy.rb', line 45

def on_master(proxy_target = nil, &block)
  on_db(nil, proxy_target, &block)
end

#on_slave(con = nil, proxy_target = nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


39
40
41
42
43
# File 'lib/db_charmer/multi_db_proxy.rb', line 39

def on_slave(con = nil, proxy_target = nil, &block)
  con ||= db_charmer_random_slave
  raise ArgumentError, "No slaves found in the class and no slave connection given" if con.nil? && DbCharmer.switch_connections?
  on_db(con, proxy_target, &block)
end