Module: SlavePoolsModule::ObserverExtensions
- Defined in:
- lib/slave_pools/observer_extensions.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#update_with_masterdb(observed_method, object, &block) ⇒ Object
Send observed_method(object) if the method exists.
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/slave_pools/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, &block) ⇒ Object
Send observed_method(object) if the method exists. currently replicating the update method instead of using the aliased method call to update_without_master
9 10 11 12 13 14 15 16 17 |
# File 'lib/slave_pools/observer_extensions.rb', line 9 def update_with_masterdb(observed_method, object, &block) #:nodoc: if object.class.connection.respond_to?(:with_master) object.class.connection.with_master do send(observed_method, object, &block) if respond_to?(observed_method) && !disabled_for?(object) end else send(observed_method, object, &block) if respond_to?(observed_method) && !disabled_for?(object) end end |