Module: MultiDb::ObserverExtensions

Defined in:
lib/multi_db/observer_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/multi_db/observer_extensions.rb', line 3

def self.included(base)
  base.alias_method_chain :update, :masterdb
end

Instance Method Details

#update_with_masterdb(observed_method, object) ⇒ Object

Send observed_method(object) if the method exists.



8
9
10
11
12
13
14
15
16
# File 'lib/multi_db/observer_extensions.rb', line 8

def update_with_masterdb(observed_method, object) #:nodoc:
  if object.class.connection.respond_to?(:with_master)
    object.class.connection.with_master do
      update_without_masterdb(observed_method, object)
    end
  else
    update_without_masterdb(observed_method, object)
  end
end