Expression.Context (expression v2.23.9)

A helper module for creating a context that can be used with Expression.Eval


iex>{foo: "bar"}) %{"foo" => "bar"} iex>{FOO: "bar"}) %{"foo" => "bar"} iex>{foo: %{bar: "baz"}}) %{"foo" => %{"bar" => "baz"}} iex>{Foo: %{Bar: "baz"}}) %{"foo" => %{"bar" => "baz"}} iex>{foo: %{bar: 1}}) %{"foo" => %{"bar" => 1}} iex>{date: "2020-12-13T23:34:45"}) %{"date" => ~U[2020-12-13 23:34:45.0Z]} iex>{boolean: "true"}) %{"boolean" => true} iex>{float: 1.234}) %{"float" => 1.234} iex> now = DateTime.utc_now() iex> ctx ={float: "1.234", nested: %{date: now}}) iex> ctx["float"] 1.234 iex> now == ctx["nested"]["date"] true iex>{mixed: ["2020-12-13T23:34:45", 1, "true", "binary"]}) %{"mixed" => [~U[2020-12-13 23:34:45.0Z], 1, true, "binary"]}

Link to this section Summary

Link to this section Types

@type t() :: map()

Link to this section Functions

@spec new(map()) :: t()