class StateMachine::SendEventTransition

This is kind of the ‘standard’ transition. It is created when supplying the :on option in the state machine definition.

If armed, the transition is triggered when sending an event to the state machine by calling {StateMachine::Base#event} with the event’s symbol as parameter. Sending the same event symbol while not armed will just ignore the event.

Note that you should call the {StateMachine::Base#event} method from the same queue / thread where the state machine was started.

@example Create a {SendEventTransition}:

state_machine.when :sleeping do |state|
  state.transition_to :awake, on: :foo
end

state_machine.event :foo
  # => state machine goes to :awake state

Public Class Methods

new(options) click to toggle source
Calls superclass method StateMachine::Transition::new
# File lib/motion-state-machine/transition.rb, line 280
def initialize(options)
  super(options)
  unarm
end

Public Instance Methods

arm() click to toggle source
# File lib/motion-state-machine/transition.rb, line 289
def arm
  state_machine.register_event_handler event_trigger_value, self
end
event_description() click to toggle source
# File lib/motion-state-machine/transition.rb, line 285
def event_description
  "after #{event_trigger_value}"
end
unarm() click to toggle source
# File lib/motion-state-machine/transition.rb, line 293
def unarm
  state_machine.register_event_handler event_trigger_value, nil
end