AshWorkflow.Entities.Transition (AshWorkflow v0.6.0)

Copy Markdown View Source

A named transition from a manual step to another step.

Simple transitions have a static to target:

transition :approve, to: :done

Conditional transitions have routes instead — multiple targets with when conditions:

transition :complete do
  route :training, when: expr(path_type == :agency)
  route :ready, when: expr(path_type == :family)
end

A transition must have either to or at least one route, not both.

Routes are evaluated in declaration order and the first match wins. Conditions see the record as it was loaded with the transition's accept list applied, so a route can branch on an attribute the same call accepted, while an attribute written by the action's own changes stays invisible:

transition :decide do
  accept [:decision]
  route :approved, when: expr(decision == :approve)
  route :rejected, when: expr(decision == :reject)
end

Summary

Types

t()

@type t() :: %AshWorkflow.Entities.Transition{
  __spark_metadata__: term(),
  accept: [atom()],
  name: atom(),
  routes: [AshWorkflow.Entities.Route.t()],
  to: atom() | nil,
  undoable?: boolean()
}

Functions

all_targets(transition)

attribute_schema()

conditional?(arg1)