View Source Ash.Query.Function behaviour (ash v3.4.48)
A function is a predicate with an arguments list.
For more information on being a predicate, see Ash.Filter.Predicate
. Most of the complexities
are there. A function must meet both behaviours.
Summary
Callbacks
The number and types of arguments supported.
Whether or not the function return nil.
Whether or not the function can be evaluated eagerly. For example, now()
cannot be.
Evaluate a function when all arguments are known valid values
If true
, will be allowed to evaluate nil
inputs.
The name of the function
Instantiate a new function with the provided arguments
Evaluate a function when some or no arguments are known valid values
Whether or not the function is a predicate (takes a reference as the first argument, a value as the second, and returns a boolean)
Whether or not the function should be usable when parsing input.
The return type for each corresponding set of args.
Functions
Evaluate the operator with provided inputs
Attaches the appropriate suffix to refer to an ordinal number, e.g 1 -> "1st"
Types
@type arg() :: any()
Callbacks
@callback args() :: [arg()] | :var_args
The number and types of arguments supported.
Whether or not the function return nil.
@callback eager_evaluate?() :: boolean()
Whether or not the function can be evaluated eagerly. For example, now()
cannot be.
Evaluate a function when all arguments are known valid values
@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 name() :: atom()
The name of the function
@callback new([term()]) :: {:ok, term()} | {:error, String.t() | Exception.t()}
Instantiate a new function with the provided arguments
Evaluate a function when some or no arguments are known valid values
@callback predicate?() :: boolean()
Whether or not the function is a predicate (takes a reference as the first argument, a value as the second, and returns a boolean)
@callback private?() :: boolean()
Whether or not the function should be usable when parsing input.
@callback returns() :: [Ash.Type.t() | {Ash.Type.t(), constraints :: Keyword.t()}] | Ash.Type.t() | {Ash.Type.t(), constraints :: Keyword.t()} | :unknown
The return type for each corresponding set of args.