View Source Bonfire.Ecto.Acts.Begin (Bonfire v0.9.10-classic-beta.169)
An Act that enters a transaction unless it senses that it would be futile.
Summary
Functions
Runs the given act(s) within a transaction if no errors are detected in the epic.
Functions
Runs the given act(s) within a transaction if no errors are detected in the epic.
This function takes the modules before the Commit
module in the epic.next
list, runs them,
and then processes the remaining modules. If there are any errors in the epic, it avoids
entering a transaction.
Parameters
epic
- The epic struct that contains the list of acts to be executed.act
- The current act being processed.
Examples
iex> epic = %Epic{next: [%{module: OtherModule}, %{module: Commit}], errors: []}
iex> act = %{}
iex> Bonfire.Ecto.Acts.Begin.run(epic, act)
%Epic{next: [], errors: []}
iex> epic = %Epic{next: [%{module: OtherModule}, %{module: Commit}], errors: ["error"]}
iex> act = %{}
iex> Bonfire.Ecto.Acts.Begin.run(epic, act)
%Epic{next: [], errors: ["error"]}