improvement: require from/to

This commit is contained in:
Zach Daniel 2023-04-22 18:12:11 -06:00
parent 885fd2c79b
commit 98afe7b59f
3 changed files with 6 additions and 13 deletions

View file

@ -1,12 +1,12 @@
spark_locals_without_parens = [
default_initial_state: 1,
deprecated_states: 1,
transition: 1,
transition: 2,
from: 1,
initial_states: 1,
state_attribute: 1,
to: 1
to: 1,
transition: 1,
transition: 2
]
# Used by "mix format"

View file

@ -28,11 +28,13 @@ defmodule AshStateMachine do
],
from: [
type: {:or, [{:list, :atom}, :atom]},
required: true,
doc:
"The states in which this action may be called. If not specified, then any state is accepted."
],
to: [
type: {:or, [{:list, :atom}, :atom]},
required: true,
doc:
"The states that this action may move to. If not specified, then any state is accepted."
]

View file

@ -46,15 +46,6 @@ defmodule AshStateMachine.Transformers.FillInTransitionDefaults do
Transformer.set_option(dsl_state, [:state_machine], :initial_states, all_states)
end
{:ok,
transitions
|> Enum.reduce(dsl_state, fn transition, dsl_state ->
Transformer.replace_entity(dsl_state, [:state_machine], %{
transition
| from: transition.from || all_states,
to: transition.to || all_states
})
end)
|> Transformer.persist(:all_state_machine_states, all_states)}
{:ok, Transformer.persist(dsl_state, :all_state_machine_states, all_states)}
end
end