View Source ChannelHandler.Context (channel_handler v0.6.3)
Link to this section Summary
Link to this section Types
Link to this section Functions
Puts a value in the context bindings.
If the key is already present in the bindings, the value is overwritten.
examples
Examples
iex> context = %Context{bindings: %{foo: 1}}
iex> assign(context, :foo, 2)
%Context{bindings: %{foo: 2}}
iex> assign(context, :bar, 2)
%Context{bindings: %{foo: 1, bar: 2}}
Assigns a new value to the context bindings.
If the key is already present in the bindings, the context is returned.
examples
Examples
iex> context = %Context{bindings: %{foo: 1}}
iex> assign_new(context, :foo, fn -> 2 end)
%Context{bindings: %{foo: 1}}
iex> assign_new(context, :bar, fn -> 2 end)
%Context{bindings: %{foo: 1, bar: 2}}