class FSM::Machine

Overview

Represents a finite state machine.

@property id [String] The unique identifier of the state machine. @property states [Hash(String, State)] A collection of states associated with the state machine. @property initial_state [State] The initial state of the state machine. @property current_state [State] The current state of the state machine.

Defined in:

fsm/machine.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.create(id : String, states : Array(State)) #

Create a new state machine with the given identifier, states, and initial state.

@param id [String] The unique identifier of the state machine. @param states [Array(State)] The states associated with the state machine. @param context [Hash(String, Any)] Optional initial data to be registered in the context. @yieldparam self [Machine] The machine instance to be configured.


[View source]
def self.create(id : String, states : Array(State), &) #

Create a new state machine with the given identifier, states, initial state, and execute a block to set up additional configurations.

@param id [String] The unique identifier of the state machine. @param states [Array(State)] The states associated with the state machine. @param context [Hash(String, Any)] Optional initial data to be registered in the context. @yieldparam self [Machine] The machine instance to be configured.


[View source]

Instance Method Detail

def id : String #

The unique identifier of the state machine.


[View source]
def states : Hash(String, State) #

A collection of states associated with the state machine.


[View source]