Expression.Context (expression v2.23.9)

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

Example

iex> Expression.Context.new(%{foo: "bar"}) %{"foo" => "bar"} iex> Expression.Context.new(%{FOO: "bar"}) %{"foo" => "bar"} iex> Expression.Context.new(%{foo: %{bar: "baz"}}) %{"foo" => %{"bar" => "baz"}} iex> Expression.Context.new(%{Foo: %{Bar: "baz"}}) %{"foo" => %{"bar" => "baz"}} iex> Expression.Context.new(%{foo: %{bar: 1}}) %{"foo" => %{"bar" => 1}} iex> Expression.Context.new(%{date: "2020-12-13T23:34:45"}) %{"date" => ~U[2020-12-13 23:34:45.0Z]} iex> Expression.Context.new(%{boolean: "true"}) %{"boolean" => true} iex> Expression.Context.new(%{float: 1.234}) %{"float" => 1.234} iex> now = DateTime.utc_now() iex> ctx = Expression.Context.new(%{float: "1.234", nested: %{date: now}}) iex> ctx["float"] 1.234 iex> now == ctx["nested"]["date"] true iex> Expression.Context.new(%{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()