class FSM::Service

Defined in:

fsm/service.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.interpret(machine : Machine, initial_state : String, context : Hash(String, Any) | Nil = nil) #

[View source]

Instance Method Detail

def current_state : String #

[View source]
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.


[View source]
def on_transition(&block : State -> ) : self #

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

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


[View source]
def 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.


[View source]