ash v0.1.1 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 delete. 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.

Authorization in ash is done via supplying a list of rules to actions in the rules option. To understand rules and authorization, see the documentation in Ash.Authorization

Link to this section Summary

Functions

Returns an allow rule. See Ash.Authorization.Rule.new/2 for more.

Returns an allow_only rule. See Ash.Authorization.Rule.new/2 for more.

Returns an allow_unless rule. See Ash.Authorization.Rule.new/2 for more.

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

Returns a deny rule. See Ash.Authorization.Rule.new/2 for more.

Returns a deny_only rule. See Ash.Authorization.Rule.new/2 for more.

Returns a deny_unless rule. See Ash.Authorization.Rule.new/2 for more.

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

allow(check, opts \\ [])

View Source (macro)

Returns an allow rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

allow_only(check, opts \\ [])

View Source (macro)

Returns an allow_only rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

allow_unless(check, opts \\ [])

View Source (macro)

Returns an allow_unless rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

create(name, opts \\ [])

View Source (macro)

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


Opts

  • primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: false
  • authorization_steps([%Ash.Authorization.Rule{}]): A list of Ash.Authorization.Rules that will be stepped through and applied in order. - Default: []

Examples

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

deny(check, opts \\ [])

View Source (macro)

Returns a deny rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

deny_only(check, opts \\ [])

View Source (macro)

Returns a deny_only rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

deny_unless(check, opts \\ [])

View Source (macro)

Returns a deny_unless rule. See Ash.Authorization.Rule.new/2 for more.

Link to this macro

destroy(name, opts \\ [])

View Source (macro)

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


Opts

  • primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: false
  • authorization_steps([%Ash.Authorization.Rule{}]): A list of Ash.Authorization.Rules that will be stepped through and applied in order. - Default: []

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.


Opts

  • primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: false
  • paginate?(boolean): If false, a page is still returned from a read action, but no limit or offset is performed. - Default: true
  • authorization_steps([%Ash.Authorization.Rule{}]): A list of Ash.Authorization.Rules that will be stepped through and applied in order. - Default: []

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.


Opts

  • primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: false
  • authorization_steps([%Ash.Authorization.Rule{}]): A list of Ash.Authorization.Rules that will be stepped through and applied in order. - Default: []

Examples

update :flag_for_review, primary?: true