Class: Ohm::State
- Inherits:
-
Object
- Object
- Ohm::State
- Defined in:
- lib/ohm/stateful_model.rb
Instance Attribute Summary collapse
-
#after_transition_proc ⇒ Object
Returns the value of attribute after_transition_proc.
Class Method Summary collapse
- .add_callbacks_to(obj) ⇒ Object
- .state_machine(*args, &block) ⇒ Object
- .state_machine_without_additions ⇒ Object
Instance Attribute Details
#after_transition_proc ⇒ Object
Returns the value of attribute after_transition_proc.
89 90 91 |
# File 'lib/ohm/stateful_model.rb', line 89 def after_transition_proc @after_transition_proc end |
Class Method Details
.add_callbacks_to(obj) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/ohm/stateful_model.rb', line 105 def add_callbacks_to(obj) obj.instance_eval do after_transition do |obj, transition| if obj.after_transition_proc obj.after_transition_proc.call(obj, transition) end end end end |
.state_machine(*args, &block) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/ohm/stateful_model.rb', line 95 def state_machine(*args, &block) if block state_machine_without_additions(*args, &block).tap do |machine| add_callbacks_to(machine) end else state_machine_without_additions(*args) end end |
.state_machine_without_additions ⇒ Object
93 |
# File 'lib/ohm/stateful_model.rb', line 93 alias_method :state_machine_without_additions, :state_machine |