ash v1.11.0 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

calculation :full_name, MyApp.MyResource.FullName
calculation :full_name, {MyApp.FullName, keys: [:first_name, :last_name]}
calculation :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