ash v1.24.1 Ash.Resource.Dsl.Calculate View Source

Link to this section Summary

Functions

Declares a named calculation on the resource.

Link to this section Functions

Link to this macro

calculate(name, calculation, opts \\ [])

View Source (macro)

Declares a named calculation on the resource.

Takes a module that must adopt the Ash.Calculation behaviour. See that module for more information.

Examples

calculate :full_name, MyApp.MyResource.FullName
calculate :full_name, {MyApp.FullName, keys: [:first_name, :last_name]}
calculate :full_name, full_name([:first_name, :last_name])

Arguments

  • :name - The field name to use for the calculation value

  • :calculation - The module or {module, opts} to use for the calculation

Options

  • :description - An optional description for the calculation

  • :private? - Whether or not the calculation will appear in any interfaces created off of this resource, e.g AshJsonApi and AshGraphql The default value is false.