Module: Dunlop::WorkflowInstanceModel::WorkflowStepHandling::ClassMethods

Defined in:
app/models/dunlop/workflow_instance_model/workflow_step_handling.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scenario_workflow_step_namesObject (readonly)

Returns the value of attribute scenario_workflow_step_names.



63
64
65
# File 'app/models/dunlop/workflow_instance_model/workflow_step_handling.rb', line 63

def scenario_workflow_step_names
  @scenario_workflow_step_names
end

Instance Method Details

#possible_workflow_step_namesObject



74
75
76
# File 'app/models/dunlop/workflow_instance_model/workflow_step_handling.rb', line 74

def possible_workflow_step_names
  @@possible_workflow_step_names
end

#setup_possible_workflow_steps(possible_workflow_step_names) ⇒ Object



78
79
80
# File 'app/models/dunlop/workflow_instance_model/workflow_step_handling.rb', line 78

def setup_possible_workflow_steps(possible_workflow_step_names)
  @@possible_workflow_step_names = possible_workflow_step_names
end

#setup_scenario_workflow_steps(step_names) ⇒ Object

used to setup the workflow step inside a scenario class



66
67
68
69
70
71
72
# File 'app/models/dunlop/workflow_instance_model/workflow_step_handling.rb', line 66

def setup_scenario_workflow_steps(step_names)
  raise "setup_workflow_steps is meant to use inside a scenario class" unless self.name.include?('::')
  if illegal_step_names = (step_names - possible_workflow_step_names).presence
    raise "You cannot specify scenario workflow steps that are not given as possible workflow steps. Extra steps were: #{illegal_step_names.join(', ')}"
  end
  @scenario_workflow_step_names = step_names
end

#workflow_step_classesObject

Return the the workflow_step classes for the WorkflowInstance. At



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'app/models/dunlop/workflow_instance_model/workflow_step_handling.rb', line 84

def workflow_step_classes
  scenario_class_name = name.demodulize
  if scenario_class_name == name
    # method invoked on base class
    possible_workflow_step_names.map do |step_name|
      step_name.to_s.classify.constantize
    end
  else
    # method invoked on scenario class
    scenario_workflow_step_names.map do |step_name|
      "#{step_name.to_s.classify}::#{scenario_class_name}".constantize
    end
  end
end