Module: Stateflow::ClassMethods
- Defined in:
- lib/stateflow.rb
Instance Attribute Summary collapse
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Instance Method Summary collapse
Instance Attribute Details
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
17 18 19 |
# File 'lib/stateflow.rb', line 17 def machine @machine end |
Instance Method Details
#stateflow(&block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stateflow.rb', line 19 def stateflow(&block) @machine = Stateflow::Machine.new(&block) @machine.states.values.each do |state| state_name = state.name define_method "#{state_name}?" do state_name == current_state.name end end @machine.events.keys.each do |key| define_method "#{key}" do fire_event(key, :save => false) end define_method "#{key}!" do fire_event(key, :save => true) end end end |