View Source Ash.Query.Operator behaviour (ash v3.4.46)
An operator is a predicate with a left
and a right
For more information on being a predicate, see Ash.Filter.Predicate
. Most of the complexities
are there. An operator must meet both behaviours.
Summary
Callbacks
Whether or not the operator can evaluate to nil.
Evaluates the operator in Elixir
If true
, will be allowed to evaluate nil
inputs.
Create a new predicate. There are various return types possible
The types that the expression can return. Should be one entry in the list for each entry in types
.
The implementation of the inspect protocol.
The types accepted by the operator. Defaults to [:same, :any]
, which is any values of the same type.
Functions
Evaluate the operator with provided inputs
Create a new operator. Pass the module and the left and right values
Get type overloads for the given operator
Callbacks
Whether or not the operator can evaluate to nil.
Evaluates the operator in Elixir
@callback evaluate_nil_inputs?() :: boolean()
If true
, will be allowed to evaluate nil
inputs.
If false
(the default), any nil
inputs will cause a nil
return.
@callback new(term(), term()) :: {:ok, term(), term()} | {:ok, term()} | {:known, boolean()} | {:error, term()}
Create a new predicate. There are various return types possible:
{:ok, left, right}
- Return the left/right values of the operator{:ok, operator}
- Return the operator itself, this or the one above are acceptable{:known, boolean}
- If the value is already known, e.g1 == 1
{:error, error}
- If there was an error creating the operator
@callback predicate?() :: boolean()
@callback returns() :: [ :any | :same | Ash.Type.t() | {Ash.Type.t(), constraints :: Keyword.t()} ]
The types that the expression can return. Should be one entry in the list for each entry in types
.
@callback to_string( struct(), Inspect.Opts.t() ) :: term()
The implementation of the inspect protocol.
If not defined, it will be inferred
@callback types() :: [ :any | :same | [Ash.Type.t() | {Ash.Type.t(), constraints :: Keyword.t()}] ]
The types accepted by the operator. Defaults to [:same, :any]
, which is any values of the same type.