Class: DbCharmer::MultiDbProxy::OnDbProxy

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/db_charmer/multi_db_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_class, slave) ⇒ OnDbProxy

Returns a new instance of OnDbProxy.



4
5
6
7
# File 'lib/db_charmer/multi_db_proxy.rb', line 4

def initialize(model_class, slave)
  @model = model_class
  @slave = slave
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



11
12
13
14
15
# File 'lib/db_charmer/multi_db_proxy.rb', line 11

def method_missing(meth, *args, &block)
  @model.on_db(@slave) do |m|
    m.__send__(meth, *args, &block)
  end
end