mirror of
https://github.com/ash-project/ash_state_machine.git
synced 2024-09-19 21:03:33 +12:00
improvement: require from/to
This commit is contained in:
parent
885fd2c79b
commit
98afe7b59f
3 changed files with 6 additions and 13 deletions
|
@ -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"
|
||||
|
|
|
@ -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."
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue