class FSM::Service
- FSM::Service
- Reference
- Object
Defined in:
fsm/service.crClass Method Summary
Instance Method Summary
- #current_state : String
-
#matches?(state_id : String)
Check if the state machine is in a specific state.
-
#on_transition(&block : State -> ) : self
Register a callback to be executed when the state of the machine changes.
-
#send(event : String) : State
Send an event to trigger a state transition.
Class Method Detail
def self.interpret(machine : Machine, initial_state : String, context : Hash(String, Any) | Nil = nil)
#
Instance Method Detail
def matches?(state_id : String)
#
Check if the state machine is in a specific state.
@param state_id [String] The identifier of the state to check. @return [Bool] True if the state machine is in the specified state, false otherwise.
Register a callback to be executed when the state of the machine changes.
@yieldparam state [State] The new state after the change.
Send an event to trigger a state transition.
@param event [String] The event triggering the transition. @return [State] The new state after the transition.