Class: StateMachine::Integrations::ActiveModel::ObserverUpdate
- Inherits:
-
Object
- Object
- StateMachine::Integrations::ActiveModel::ObserverUpdate
- Defined in:
- lib/state_machine/integrations/active_model/observer_update.rb
Overview
Represents the encapsulation of all of the details to be included in an update to state machine observers. This allows multiple arguments to get passed to an observer method (instead of just a single object
) while still respecting the way in which ActiveModel checks for the object’s list of observers.
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
The method to invoke on the observer.
-
#object ⇒ Object
readonly
The object being transitioned.
-
#transition ⇒ Object
readonly
The transition being run.
Instance Method Summary collapse
-
#args ⇒ Object
The arguments to pass into the method.
-
#class ⇒ Object
The class of the object being transitioned.
-
#initialize(method, object, transition) ⇒ ObserverUpdate
constructor
:nodoc:.
Constructor Details
#initialize(method, object, transition) ⇒ ObserverUpdate
:nodoc:
19 20 21 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 19 def initialize(method, object, transition) #:nodoc: @method, @object, @transition = method, object, transition end |
Instance Attribute Details
#method ⇒ Object (readonly)
The method to invoke on the observer
11 12 13 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 11 def method @method end |
#object ⇒ Object (readonly)
The object being transitioned
14 15 16 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 14 def object @object end |
#transition ⇒ Object (readonly)
The transition being run
17 18 19 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 17 def transition @transition end |
Instance Method Details
#args ⇒ Object
The arguments to pass into the method
24 25 26 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 24 def args [object, transition] end |
#class ⇒ Object
The class of the object being transitioned. Normally the object getting passed into observer methods is the actual instance of the ActiveModel class. ActiveModel uses that instance’s class to check for enabled / disabled observers.
Since state_machine is passing an ObserverUpdate instance into observer methods, class
needs to be overridden so that ActiveModel can still get access to the enabled / disabled observers.
36 37 38 |
# File 'lib/state_machine/integrations/active_model/observer_update.rb', line 36 def class object.class end |