View Source Ash.Resource.Change behaviour (ash v3.0.0-rc.19)
The behaviour for an action-specific resource change.
init/1
is defined automatically by use Ash.Resource.Change
, but can be implemented if you want to validate/transform any
options passed to the module.
The main function is change/3
. It takes the changeset, any options that were provided
when this change was configured on a resource, and the context, which currently only has
the actor.
Summary
Callbacks
Runs on each batch result after it is dispatched to the data layer.
Replaces change/3
for batch actions, allowing to optimize changes for bulk actions.
Runs on each batch before it is dispatched to the data layer.
Types
Callbacks
@callback after_atomic( Ash.Changeset.t(), Keyword.t(), Ash.Resource.record(), Ash.Resource.Change.Context.t() ) :: {:ok, Ash.Resource.record()} | {:error, term()}
@callback after_batch( changesets_and_results :: [{Ash.Changeset.t(), Ash.Resource.record()}], opts :: Keyword.t(), context :: Ash.Resource.Change.Context.t() ) :: Enumerable.t( {:ok, Ash.Resource.record()} | {:error, Ash.Error.t()} | Ash.Notifier.Notification.t() )
Runs on each batch result after it is dispatched to the data layer.
@callback atomic(Ash.Changeset.t(), Keyword.t(), Ash.Resource.Change.Context.t()) :: {:ok, Ash.Changeset.t()} | {:atomic, %{optional(atom()) => Ash.Expr.t() | {:atomic, Ash.Expr.t()}}} | {:atomic, Ash.Changeset.t(), %{optional(atom()) => Ash.Expr.t()}} | {:not_atomic, String.t()} | :ok | {:error, term()}
@callback atomic?() :: boolean()
@callback batch_change( changesets :: [Ash.Changeset.t()], opts :: Keyword.t(), context :: Ash.Resource.Change.Context.t() ) :: Enumerable.t(Ash.Changeset.t() | Ash.Notifier.Notification.t())
Replaces change/3
for batch actions, allowing to optimize changes for bulk actions.
@callback before_batch( changesets :: [Ash.Changeset.t()], opts :: Keyword.t(), context :: Ash.Resource.Change.Context.t() ) :: Enumerable.t(Ash.Changeset.t() | Ash.Notifier.Notification.t())
Runs on each batch before it is dispatched to the data layer.
@callback change( changeset :: Ash.Changeset.t(), opts :: Keyword.t(), context :: Ash.Resource.Change.Context.t() ) :: Ash.Changeset.t()
@callback has_change?() :: boolean()