module FlowChart::InstanceMethods
Attributes
previous_state[RW]
Public Instance Methods
current_state()
click to toggle source
# File lib/flow_chart.rb, line 64 def current_state if (flowprocessor.state_column.to_sym.nil? or send(flowprocessor.state_column.to_sym).nil? or send(flowprocessor.state_column.to_sym)=="") @current_state ||= flowprocessor.flowstates[flowprocessor.starting_flowstate.flowstatename] else @current_state ||= flowprocessor.flowstates[send(flowprocessor.state_column.to_sym).to_sym] end @current_state end
current_work_owners()
click to toggle source
# File lib/flow_chart.rb, line 84 def current_work_owners @current_work_owners ||= workprocessor.delegate_actions.map{|work_name,work_owners| {work_name=>work_owners.current_work_owners}} @current_work_owners end
flowprocessor()
click to toggle source
# File lib/flow_chart.rb, line 60 def flowprocessor self.class.flowprocessor end
set_current_state(new_state, options = {})
click to toggle source
# File lib/flow_chart.rb, line 73 def set_current_state(new_state, options = {}) send("#{flowprocessor.state_column}=".to_sym, new_state.flowstatename.to_s) @current_state = new_state send("#{flowprocessor.state_column.to_s}=".to_sym,"#{current_state.flowstatename.to_s.to_s}") #Updates the instance variable # If asked to save action with bang! and if inherits from ActiveRecord in Rails then do save! ## Important check to support both Non-ActiveRecord Models in Ruby and ActiveRecord Models in Rails if options[:save_object] and !(defined?(ActiveRecord::Base).nil?) and self.class.ancestors.include? ActiveRecord::Base self.save end end
set_current_work_owners(options = {})
click to toggle source
# File lib/flow_chart.rb, line 89 def set_current_work_owners(options = {}) @current_work_owners = workprocessor.delegate_actions.map{|work_name,work_owners| {work_name=>work_owners.current_work_owners}} send("#{workprocessor.assigned_to_column}=".to_sym, YAML.dump(current_work_owners.map{|work| work.map{|work_name,owners| {work_name=>owners[workprocessor.assigned_to_column.to_sym]||""}}}.flatten)) send("#{workprocessor.assigned_by_column}=".to_sym, YAML.dump(current_work_owners.map{|work| work.map{|work_name,owners| {work_name=>owners[workprocessor.assigned_by_column.to_sym]||""}}}.flatten)) if options[:save_object] and !(defined?(ActiveRecord::Base).nil?) and self.class.ancestors.include? ActiveRecord::Base self.save end end
workprocessor()
click to toggle source
# File lib/flow_chart.rb, line 56 def workprocessor self.class.workprocessor end
Private Instance Methods
process_action(action_name,options_for_action = {})
click to toggle source
# File lib/flow_chart.rb, line 99 def process_action(action_name,options_for_action = {}) action = flowprocessor.actions[action_name.to_sym] if action.nil? p "Error: #{action_name} not found!" raise FlowChart::InvalidState.new("Error: #{action_name} not found!") end action.process_action!(self,current_state,options_for_action) end
process_delegate_action(action_name,assigned_to,assigned_by,options_for_delegate_action={})
click to toggle source
# File lib/flow_chart.rb, line 108 def process_delegate_action(action_name,assigned_to,assigned_by,options_for_delegate_action={}) delegate_action = workprocessor.delegate_actions[action_name.to_sym] if delegate_action.nil? p "Error: #{action_name} not found!" raise FlowChart::InvalidWorkDelegateAction.new("Error: #{delegate_action} not found!") end delegate_action.process_delegate_action!(self,current_work_owners,assigned_to,assigned_by,options_for_delegate_action) end