-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Similar to other !
suffixed functions, the thought would be to either return the transformed struct or raise an error. The goal of this change would be to allow the transition_to!
call to be chained in a pipeline.
Given:
defmodule MyStateMachine do
use Machinery,
states: ~w(pending completed),
transitions: %{"pending" => ["completed"]}
end
defmodule MyStruct do
defstruct [:state]
end
The spec for the function(s) may look something like this:
Machinery.transition_to!(%MyStruct{state: "pending"}, MyStateMachine, "completed")
# %MyStruct{state: "completed"}
Machinery.transition_to!(%MyStruct{state: "completed"}, MyStateMachine, "pending")
# raise Machinery.Errors.UndeclaredTransition
jcserracampos
Metadata
Metadata
Assignees
Labels
No labels