ash v0.1.8 Ash.Resource.Actions View Source

DSL components for declaring resource actions.

All manipulation of data through the underlying data layer happens through actions. There are four types of action: create, read, update, and destroy. You may recognize these from the acronym CRUD. You can have multiple actions of the same type, as long as they have different names. This is the primary mechanism for customizing your resources to conform to your business logic. It is normal and expected to have multiple actions of each type in a large application.

If you have multiple actions of the same type, one of them must be designated as the primary action for that type, via: primary?: true. This tells the ash what to do if an action of that type is requested, but no specific action name is given.

Link to this section Summary

Functions

Declares a create action. For calling this action, see the Ash.Api documentation.

Declares an destroy action. For calling this action, see the Ash.Api documentation.

Declares a read action. For calling this action, see the Ash.Api documentation.

Declares an update action. For calling this action, see the Ash.Api documentation.

Link to this section Functions

Link to this macro

create(name, opts \\ [])

View Source (macro)

Declares a create action. For calling this action, see the Ash.Api documentation.

  • :primary? - Whether or not this action should be used when no action is specified by the caller. The default value is false.

Examples

create :register, primary?: true
Link to this macro

destroy(name, opts \\ [])

View Source (macro)

Declares an destroy action. For calling this action, see the Ash.Api documentation.

  • :primary? - Whether or not this action should be used when no action is specified by the caller. The default value is false.

Examples

destroy :soft_delete, primary?: true
Link to this macro

read(name, opts \\ [])

View Source (macro)

Declares a read action. For calling this action, see the Ash.Api documentation.

  • :primary? - Whether or not this action should be used when no action is specified by the caller. The default value is false.

Examples

read :read_all, primary?: true
Link to this macro

update(name, opts \\ [])

View Source (macro)

Declares an update action. For calling this action, see the Ash.Api documentation.

  • :primary? - Whether or not this action should be used when no action is specified by the caller. The default value is false.

Examples

update :flag_for_review, primary?: true