defmodule Expression.V2.Context do
@moduledoc """
The context supplied to a function generated by `Expression.V2.Compile.compile/1`
This will be expanded with support for more attributes that a callback function
can access but normal Expression evaluation can not.
"""
defstruct vars: %{}, private: %{}, callback_module: Expression.V2.Callbacks.Standard
@type t :: %__MODULE__{
vars: map,
private: map,
callback_module: module
}
def new(vars \\ %{}, callback_module \\ Expression.V2.Callbacks.Standard),
do: %__MODULE__{vars: vars, callback_module: callback_module}
def private(ctx, key, value), do: %{ctx | private: Map.put(ctx.private, key, value)}
end