Module: StateGate::Engine::Configurator
- Included in:
- StateGate::Engine
- Defined in:
- lib/state_gate/engine/configurator.rb
Overview
Description
Parses the configuration for StateGate::Engine.
The configuration defines the state names, allowed transitions and a number of options to help customise the state-gate to your exact preference.
Options include:
[state]
Required name for the new state, supplied as a Symbol. The state-gate requires
a minimum of two states to be defined.
state :state_name
**_:transitions_to_**
An optional list of the other state that this state is allowed to change to.
state :state_1, transtions_to: [:state_2, :state_3, :state_4]
state :state_2, transtions_to: :state_4
state :state_3, transtions_to: :any
state :state_4
**_:human_**
An optional String name to used when displaying gthe state in a view. If no
name is specified, it will default to +:state.titleized+.
state :state_1, transtions_to: [:state_2, :state_3], human: "My State"
[default] Optional setting to specify the default state for a new object. The state name is given as a Symbol. default :state_name
[prefix] Optional setting to add a given Symbol before each state name when using Class Scopes. This helps to differential between multiple attributes that have similar state names. prefix :before #=> Class.before_active
[suffix] Optional setting to add a given Symbol after each state name when using Class Scopes. This helps to differential between multiple attributes that have similar state names. suffix :after #=> Class.active_after
[make_sequential] Optional setting to automatically add transitions from each state to both the preceeding and following states. make_sequential
**_:one_way_**
Option to restrict the generated transitions to one directtion only: from each
state to the follow state.
make_sequential :one_way
**_:loop_**
Option to add transitions from the last state to the first and, unless +:one_way+
is specified, also from the first state to the last.
make_sequential :one_way, :loop
[no_scopes] Optional setting to disable the generation of Class Scope helpers methods. no_scopes