Module: Dynflow::Stateful
- Included in:
- ExecutionPlan, ExecutionPlan::Steps::Abstract
- Defined in:
- lib/dynflow/stateful.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
25 26 27 |
# File 'lib/dynflow/stateful.rb', line 25 def state @state end |
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/dynflow/stateful.rb', line 3 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#set_state(state, skip_transition_check) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/dynflow/stateful.rb', line 31 def set_state(state, skip_transition_check) state = state.to_sym if state.is_a?(String) && states.map(&:to_s).include?(state) raise "unknown state #{state}" unless states.include? state unless self.state.nil? || skip_transition_check || state_transitions.fetch(self.state).include?(state) raise "invalid state transition #{self.state} >> #{state} in #{self}" end @state = state end |
#state_transitions ⇒ Object
21 22 23 |
# File 'lib/dynflow/stateful.rb', line 21 def state_transitions self.class.state_transitions end |
#states ⇒ Object
17 18 19 |
# File 'lib/dynflow/stateful.rb', line 17 def states self.class.states end |