class FSM::Context

Overview

Represents the "extended" context associated with the finite state machine.

Defined in:

fsm/context.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(initial_data = {} of String => Any) #

Create a new context with optional initial data.

@param initial_data [Hash(String, Any)] Optional initial data to be registered in the context.


[View source]

Instance Method Detail

def get(key : String) : Any #

Get the value associated with a key from the context.

@param key [String] The key to retrieve. @return [Any] The value associated with the key.


[View source]
def modify(key : String, &block : Any -> Any) #

Modify the value associated with a key in the context using a block.

@param key [String] The key to modify. @yieldparam current_value [Any] The current value associated with the key. @return [Any] The modified value.


[View source]
def set(key : String, value : Any) #

Set the value associated with a key in the context.

@param key [String] The key to set. @param value [Any] The value to associate with the key.


[View source]