state_machine v0.1.3 StateMachine.State behaviour
State module provides a structure describing a state in the state machine definition. It stores state name along with various callbacks to run before/after leaving/entering a state. Another purpose of the module is to define a behaviour for state get/setters along with the default implementation.
The state get/setters for basic structures and Ecto records are provided out of the box.
Link to this section Summary
Functions
Private function for running after_enter(state)
callbacks.
Private function for running after_leave(state)
callbacks.
Private function for running before_enter(state)
callbacks.
Private function for running before_leave(state)
callbacks.
Default implementation of a state getter.
Default implementation of a state setter.
Link to this section Types
t(model)
t(model) :: %StateMachine.State{
after_enter: [StateMachine.Callback.t(model)],
after_leave: [StateMachine.Callback.t(model)],
before_enter: [StateMachine.Callback.t(model)],
before_leave: [StateMachine.Callback.t(model)],
name: atom()
}
t(model) :: %StateMachine.State{ after_enter: [StateMachine.Callback.t(model)], after_leave: [StateMachine.Callback.t(model)], before_enter: [StateMachine.Callback.t(model)], before_leave: [StateMachine.Callback.t(model)], name: atom() }
Link to this section Functions
after_enter(ctx)
after_enter(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
after_enter(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
Private function for running after_enter(state)
callbacks.
after_leave(ctx)
after_leave(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
after_leave(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
Private function for running after_leave(state)
callbacks.
before_enter(ctx)
before_enter(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
before_enter(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
Private function for running before_enter(state)
callbacks.
before_leave(ctx)
before_leave(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
before_leave(StateMachine.Context.t(model)) :: StateMachine.Context.t(model)
Private function for running before_leave(state)
callbacks.
get(ctx)
get(StateMachine.Context.t(any())) :: atom()
get(StateMachine.Context.t(any())) :: atom()
Default implementation of a state getter.
set(ctx, state)
set(StateMachine.Context.t(model), atom()) :: StateMachine.Context.t(model)
set(StateMachine.Context.t(model), atom()) :: StateMachine.Context.t(model)
Default implementation of a state setter.
Link to this section Callbacks
get(ctx)
get(ctx :: StateMachine.Context.t(any())) :: atom()
get(ctx :: StateMachine.Context.t(any())) :: atom()
set(ctx, state)
set(ctx :: StateMachine.Context.t(model), state :: atom()) ::
StateMachine.Context.t(model)
set(ctx :: StateMachine.Context.t(model), state :: atom()) :: StateMachine.Context.t(model)