class FlowChart::Action
Driver for Actions in FlowChart
Attributes
flowprocessor[RW]
name[RW]
transitions[RW]
Public Class Methods
new(name, flowprocessor=nil, &transitions)
click to toggle source
# File lib/flowchart/flow_processor.rb, line 91 def initialize(name, flowprocessor=nil, &transitions) @name = name @flowprocessor = flowprocessor @transitions = Array.new instance_eval(&transitions) end
Public Instance Methods
process_action!(implementor_class,current_state,options_for_action)
click to toggle source
# File lib/flowchart/flow_processor.rb, line 98 def process_action!(implementor_class,current_state,options_for_action) transition = @transitions.select{ |t| t.from.include? current_state.flowstatename }.first raise InvalidTransition.new("No transition found for action #{@name}") if transition.nil? return false unless transition.shall_i_trasit?(implementor_class) new_state = implementor_class.flowprocessor.flowstates[transition.get_me_next_state(implementor_class)] raise InvalidState.new("Invalid state #{transition.to.to_s} for transition.") if new_state.nil? current_state.process_flow(:postprocess, implementor_class) implementor_class.previous_state = current_state.flowstatename.to_s new_state.process_flow(:preprocess, implementor_class) implementor_class.set_current_state(new_state,options_for_action) true end
Private Instance Methods
any()
click to toggle source
# File lib/flowchart/flow_processor.rb, line 117 def any @flowprocessor.flowstates.keys end