Class: Golem::DSL::DecisionDef
- Inherits:
-
Object
- Object
- Golem::DSL::DecisionDef
- Defined in:
- lib/golem/dsl/decision_def.rb
Instance Method Summary collapse
-
#initialize(machine, state, event) ⇒ DecisionDef
constructor
A new instance of DecisionDef.
- #method_missing? ⇒ Boolean
- #transition(options, &block) ⇒ Object
Constructor Details
#initialize(machine, state, event) ⇒ DecisionDef
Returns a new instance of DecisionDef.
7 8 9 10 11 |
# File 'lib/golem/dsl/decision_def.rb', line 7 def initialize(machine, state, event) @machine = machine @state = state @event = event end |
Instance Method Details
#method_missing? ⇒ Boolean
33 34 35 |
# File 'lib/golem/dsl/decision_def.rb', line 33 def method_missing? raise SyntaxError, "Only 'transition' declarations can be placed in a state's decision block." end |
#transition(options, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/golem/dsl/decision_def.rb', line 13 def transition(, &block) if [:to] to = @machine.states[[:to]] ||= Golem::Model::State.new([:to]) else # self-transition to = @state end if [:guard] || [:if] [:guard] = Golem::Model::Callback.new([:guard] || [:if]) # :guard and :if mean the same thing end if block || [:action] [:action] = Golem::Model::Callback.new([:action] || block) end @state.transitions_on_event[@event.name] ||= [] @state.transitions_on_event[@event.name] << Golem::Model::Transition.new(@state, to, ) end |