class Tourmaline::UpdateContext

Defined in:

tourmaline/update_context.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(hash : Hash(String, V)) forall V #

Creates UpdateContext from the given hash.


[View source]
def self.new(hash : Hash(Symbol, V)) forall V #

Creates UpdateContext from the given hash.


[View source]
def self.new(tuple : NamedTuple) #

Creates UpdateContext from the given tuple.


[View source]
def self.new #

Creates an empty UpdateContext.


[View source]

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.


[View source]
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) }

[View source]
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) }

[View source]
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) }

[View source]