Hamilton::Context
Context is a storage for some state.
As it was developed primary for Hamilton::CmdHandler, Hamilton::Context maps a key of type
Int64 | String | Symbol to a named tuple with two fields:
method : Symbol | Nil-- name of some methoddata: Hamilton::Storage)-- storage for some specific data
Constructors
Initializer of the context storage.
Optional parameters:
default_method : Symbol | Nil -- something that will be the default value for the method field
inner : Hash(Int32 | String | Symbol, NamedTuple(method: Symbol | Nil, data: Hamilton::Storage)) -- storage itself
Instance methods
Reset the context for the key, i.e. the key will map to {method: default_method, data: nil} if present.
Return the context for the key.
NOTE: if there was not a context for the key, it will be iplicitly created with {method: default_method, data: nil}.
Return the data for the key.
NOTE: if there was not a context for the key, it will be iplicitly created with {method: default_method, data: nil}.
Return the method for the key.
NOTE: if there was not a context for the key, it will be iplicitly created with {method: default_method, data: nil}.
Setter for the pair key, value.
Setter that sets only data for the key.