Module: Dunlop::WorkflowStepsInBatchFinished

Defined in:
app/services/dunlop/workflow_steps_in_batch_finished.rb

Overview

end

Defined Under Namespace

Classes: DefinitionProxy, WorkflowStepAction, WorkflowStepProxy

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ Object



45
46
47
48
# File 'app/services/dunlop/workflow_steps_in_batch_finished.rb', line 45

def self.define(&block)
  definition_proxy = DefinitionProxy.new
  definition_proxy.instance_eval(&block)
end

.final_statesObject



37
38
39
# File 'app/services/dunlop/workflow_steps_in_batch_finished.rb', line 37

def self.final_states
  @final_states
end

.final_states=(states) ⇒ Object



41
42
43
# File 'app/services/dunlop/workflow_steps_in_batch_finished.rb', line 41

def self.final_states=(states)
  @final_states = states
end

.handle_workflow_step(workflow_instance_batch, workflow_step) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'app/services/dunlop/workflow_steps_in_batch_finished.rb', line 50

def self.handle_workflow_step(workflow_instance_batch, workflow_step)
  return unless definition_proxy = registry[workflow_step.process_name.to_sym]
  batch_states = workflow_step.workflow_steps_in_batch_scope.uniq.pluck(:state)
  #return unless workflow_step.changes[:state].present?
  if batch_states.any? and (batch_states - final_states).empty?
    definition_proxy.actions.each do |action_definition|
      workflow_step.instance_exec(workflow_instance_batch, &action_definition.action)
    end
  end
end

.registryObject



33
34
35
# File 'app/services/dunlop/workflow_steps_in_batch_finished.rb', line 33

def self.registry
  @registry
end