class Roby::StateMachineDefinitionContext
Helper to get a more roby-like feeling to the state machine definitions
Attributes
state_machine[R]
task_model[R]
Public Class Methods
new(task_model, state_machine)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 9 def initialize(task_model, state_machine) @task_model = task_model @state_machine = state_machine end
Public Instance Methods
method_missing(m, *args, &block)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 45 def method_missing(m, *args, &block) state_machine.public_send(m, *args, &block) end
on(event, &block)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 37 def on(event, &block) state_machine.event(event, &block) end
poll_in_state(state, &block)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 31 def poll_in_state(state, &block) state_machine.state(state) do define_method(:poll, &block) end end
respond_to_missing?(m, include_private)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 41 def respond_to_missing?(m, include_private) state_machine.respond_to?(m) end
script_in_state(state, &block)
click to toggle source
# File lib/roby/coordination/task_state_machine.rb, line 14 def script_in_state(state, &block) script_engine = task_model.create_script(&block) state_machine.before_transition state_machine.any => state, do: lambda { |proxy| proxy.instance_variable_set :@script_engine, nil } state_machine.state(state) do define_method(:poll) do |task| if !@script_engine @script_engine = script_engine.bind(task) @script_engine.prepare @script_engine.step end end end end