class FSM::Context
- FSM::Context
- Reference
- Object
Overview
Represents the "extended" context associated with the finite state machine.
Defined in:
fsm/context.crConstructors
-
.new(initial_data = {} of String => Any)
Create a new context with optional initial data.
Instance Method Summary
-
#get(key : String) : Any
Get the value associated with a key from the context.
-
#modify(key : String, &block : Any -> Any)
Modify the value associated with a key in the context using a block.
-
#set(key : String, value : Any)
Set the value associated with a key in the context.
Constructor Detail
Create a new context with optional initial data.
@param initial_data [Hash(String, Any)] Optional initial data to be registered in the context.
Instance Method Detail
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.
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.
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.