AshWorkflow.Changes.ConditionalOnSuccess (AshWorkflow v0.6.0)

Copy Markdown View Source

An Ash change that evaluates an automatic step's on_success routes to determine the transition target.

Like AshWorkflow.Changes.ConditionalTransition, this evaluates routes against the record with the action's changes folded in — including any attributes the action computed — since the whole point of routing on on_success is to branch on what the action produced.

In practice this means evaluating against the changeset with its changes applied (but not yet persisted): this change is appended after the action's own changes, so by the time it runs, the action's business logic has already been folded into the changeset. Routes are evaluated in order. The first route whose when expression matches wins; a route with no when (an unconditional fallback) always matches. If no route matches, the changeset gets an error naming the step and the record.

Used internally by the AddActions transformer for automatic steps whose on_success needs runtime evaluation (more than one entry, or a when on its single entry). Not intended for direct use.