lib/finity/machine.rb
# An event occured, so update the state machine by evaluating the
# transition functions and notify the left and entered state, but only if
# the event leads to a transition that triggers a state change.
An event occured, so update the state machine by evaluating the
transition functions and notify the left and entered state, but only if
the event leads to a transition that triggers a state change.
An event occured so update the state machine by evaluating the transition functions and notify the left and entered state but only if the event leads to a transition that triggers a state change .
def update object, current, event
      now ||= @states[current]
      if state = @events[event].handle(object, now)
        if @states[state].nil?
          raise InvalidState, "Invalid state #{state}"
        end
        if state.eql? current
          now.cycle object
        else
          now.leave object
          now = @states[current = state]
          now.enter object
        end
      end
      current
    end
def update object , current , event now ||= @states [ current ] if state = @events [ event ] . handle ( object , now ) if @states [ state ] . nil? raise InvalidState , "Invalid state #{state}" end if state . eql? current now . cycle object else now . leave object now = @states [ current = state ] now . enter object end end current end
An event occured, so update the state machine by evaluating the
transition functions and notify the left and entered state, but only if
the event leads to a transition that triggers a state change.
An event occured so update the state machine by evaluating the transition functions and notify the left and entered state but only if the event leads to a transition that triggers a state change .
object
<not_specific>
current
<not_specific>
event
<not_specific>