class Tourmaline::UpdateContext
- Tourmaline::UpdateContext
- Reference
- Object
Defined in:
tourmaline/update_context.crConstructors
-
.new(hash : Hash(String, V)) forall V
Creates
UpdateContext
from the given hash. -
.new(hash : Hash(Symbol, V)) forall V
Creates
UpdateContext
from the given hash. -
.new(tuple : NamedTuple)
Creates
UpdateContext
from the given tuple. -
.new
Creates an empty
UpdateContext
.
Instance Method Summary
-
#merge(other : UpdateContext)
Returns a new
UpdateContext
with the keys and values of this context and other combined. -
#set(values : Hash(String, V)) forall V
Extends the context with the given values.
-
#set(values : NamedTuple)
Extends the context with the given values.
-
#set(**kwargs)
Extends the context with the given values.
Constructor Detail
Instance Method Detail
def merge(other : UpdateContext)
#
Returns a new UpdateContext
with the keys and values of this context and other combined.
A value in other takes precedence over the one in this context.
def set(values : Hash(String, V)) forall V
#
Extends the context with the given values.
update.context.set a: 1
update.context.set b: 2
update.info { %q(message with {"a" => 1, "b" => 2} context") }
extra = {:c => "3"}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => "3" } context) }
extra = {"c" => 3}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => 3 } context) }
def set(values : NamedTuple)
#
Extends the context with the given values.
update.context.set a: 1
update.context.set b: 2
update.info { %q(message with {"a" => 1, "b" => 2} context") }
extra = {:c => "3"}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => "3" } context) }
extra = {"c" => 3}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => 3 } context) }
def set(**kwargs)
#
Extends the context with the given values.
update.context.set a: 1
update.context.set b: 2
update.info { %q(message with {"a" => 1, "b" => 2} context") }
extra = {:c => "3"}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => "3" } context) }
extra = {"c" => 3}
update.context.set extra
update.info { %q(message with {"a" => 1, "b" => 2, "c" => 3 } context) }