class

FSM::Service

Inherits Reference < Object

Class methods

interpret(machine : Machine, initial_state : String, context : Hash(String, Any) | Nil = nil)
Source

Instance methods

current_state
Source
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.

Source
on_transition

Register a callback to be executed when the state of the machine changes.

@yieldparam state [State] The new state after the change.

Source
send(event : String) : State

Send an event to trigger a state transition.

@param event [String] The event triggering the transition. @return [State] The new state after the transition.

Source