AshStateMachine.BuiltinChanges (ash_state_machine v0.3.1)

Copy Markdown View Source

Changes for working with AshStateMachine resources.

Summary

Functions

Try and transition to the next state. Must be only one possible next state.

Changes the state to the target state, validating the transition

Functions

next_state(opts \\ [])

Try and transition to the next state. Must be only one possible next state.

Options

  • :recheck? - Pick the next state again in a before_action hook if the record's state has changed by then, for example because get_and_lock_for_update() read it again. Declare the lock before this change. Defaults to false.

transition_state(target, opts \\ [])

Changes the state to the target state, validating the transition

In non-atomic actions, the transition is checked against the record the action was called with, which may be out of date. See Transitions and stale records for ways to check it against the stored record instead.

Options

  • :recheck? - Check the transition again in a before_action hook if the record's state has changed by then, for example because get_and_lock_for_update() read it again. Declare the lock before this change. Defaults to false.