module Dynflow::Stateful

Attributes

state[R]

Public Class Methods

included(base) click to toggle source
# File lib/dynflow/stateful.rb, line 3
def self.included(base)
  base.extend ClassMethods
end

Public Instance Methods

set_state(state, skip_transition_check) click to toggle source
# 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=(state) click to toggle source
# File lib/dynflow/stateful.rb, line 27
def state=(state)
  set_state state, false
end
state_transitions() click to toggle source
# File lib/dynflow/stateful.rb, line 21
def state_transitions
  self.class.state_transitions
end
states() click to toggle source
# File lib/dynflow/stateful.rb, line 17
def states
  self.class.states
end