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
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.
Opts
primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: falseauthorization_steps([%Ash.Authorization.Rule{}]): A list ofAsh.Authorization.Rules that will be stepped through and applied in order. - Default: []
Examples
create :register, primary?: true
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.
Opts
primary?(boolean): Whether or not this action should be used when no action is specified by the caller. - Default: falseauthorization_steps([%Ash.Authorization.Rule{}]): A list ofAsh.Authorization.Rules that will be stepped through and applied in order. - Default: []
Examples
destroy :soft_delete, primary?: true
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: falsepaginate?(boolean): If false, a page is still returned from a read action, but no limit or offset is performed. - Default: trueauthorization_steps([%Ash.Authorization.Rule{}]): A list ofAsh.Authorization.Rules that will be stepped through and applied in order. - Default: []
Examples
read :read_all, primary?: true
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: falseauthorization_steps([%Ash.Authorization.Rule{}]): A list ofAsh.Authorization.Rules that will be stepped through and applied in order. - Default: []
Examples
update :flag_for_review, primary?: true