Ash.Type.Function (ash v3.31.0)

Copy Markdown View Source

Represents a function.

By default a function is dumped to a native format with :erlang.term_to_binary(term, [:safe]), and this is NOT SAFE to use with external input (see https://erlang.org/doc/man/erlang.html#binary_to_term-2).

With the mfa constraint the value is restricted to external captures (&Module.function/arity) and stored as a portable capture string such as "&Elixir.MyApp.callback/2", late-bound back to the function on read. This decouples the stored reference from the compiled implementation, so it survives across VMs and releases where a serialized closure would not.

Constraints

  • :mfa (boolean/0) - Restricts the value to external captures (&Module.function/arity), refusing anonymous functions and closures. Only external captures can be stored: a closure captures its environment, which cannot be rehydrated in another VM. The default value is false.

  • :arity (pos_integer/0) - Enforces a specific arity on the provided function

Summary

Functions

handle_change?()

prepare_change?()