Class: Lab42::StateMachine::DSL
- Inherits:
-
Object
- Object
- Lab42::StateMachine::DSL
- Defined in:
- lib/lab42/state_machine/dsl.rb
Constant Summary collapse
- IllegalMonitorState =
Class.new RuntimeError
Instance Attribute Summary collapse
-
#current_state ⇒ Object
readonly
Returns the value of attribute current_state.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Instance Method Summary collapse
Instance Attribute Details
#current_state ⇒ Object (readonly)
Returns the value of attribute current_state.
6 7 8 |
# File 'lib/lab42/state_machine/dsl.rb', line 6 def current_state @current_state end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
6 7 8 |
# File 'lib/lab42/state_machine/dsl.rb', line 6 def machine @machine end |
Instance Method Details
#state(designation, &blk) ⇒ Object
8 9 10 11 |
# File 'lib/lab42/state_machine/dsl.rb', line 8 def state designation, &blk @current_state = designation instance_eval(&blk) end |
#trigger(trigger_exp, new_state = nil, &blk) ⇒ Object
13 14 15 16 |
# File 'lib/lab42/state_machine/dsl.rb', line 13 def trigger trigger_exp, new_state = nil, &blk raise IllegalMonitorState unless current_state machine.add(current_state, trigger_exp, blk, new_state) end |