module Stealth::Flow
Public Instance Methods
current_flow()
click to toggle source
# File lib/stealth/flow/base.rb, line 29 def current_flow @flow || self.class.flow_spec.keys.first end
current_state()
click to toggle source
# File lib/stealth/flow/base.rb, line 24 def current_state res = self.spec.states[@flow_state.to_sym] if @flow_state res || self.spec.initial_state end
flow(flow_name, &specification)
click to toggle source
# File lib/stealth/flow/base.rb, line 14 def flow(flow_name, &specification) flow_spec[flow_name.to_sym] = Specification.new(flow_name, &specification) end
flow_and_state()
click to toggle source
# File lib/stealth/flow/base.rb, line 57 def flow_and_state [current_flow, current_state].join("->") end
init(flow:, state:)
click to toggle source
# File lib/stealth/flow/base.rb, line 41 def init(flow:, state:) new_flow = flow.to_sym new_state = state.to_sym unless state_exists?(potential_flow: new_flow, potential_state: new_state) raise(Stealth::Errors::InvalidStateTransition, "Unknown state '#{new_state}' for '#{new_flow}' flow") end @flow = new_flow @flow_state = new_state self end
spec()
click to toggle source
# File lib/stealth/flow/base.rb, line 33 def spec self.class.flow_spec[current_flow] end
state_exists?(potential_flow:, potential_state:)
click to toggle source
# File lib/stealth/flow/base.rb, line 61 def state_exists?(potential_flow:, potential_state:) if self.class.flow_spec[potential_flow].present? self.class.flow_spec[potential_flow].states.include?(potential_state) else raise(Stealth::Errors::InvalidStateTransition, "Unknown flow '#{potential_flow}'") end end
states()
click to toggle source
# File lib/stealth/flow/base.rb, line 37 def states self.spec.states.keys end