Class: BulkAction

Inherits:
ApplicationRecord show all
Defined in:
app/models/bulk_action.rb

Overview

BulkAction

Instance Method Summary collapse

Instance Method Details

#check_run_stateObject



40
41
42
43
44
# File 'app/models/bulk_action.rb', line 40

def check_run_state
  return if state_machine.current_state == "complete"

  state_machine.transition_to!(:complete) if documents.in_state(:queued).blank?
end

#revert!Object



46
47
48
49
# File 'app/models/bulk_action.rb', line 46

def revert!
  # Queue Revert Job
  BulkActionRevertJob.perform_later(self)
end

#run!Object



29
30
31
32
33
34
35
36
37
38
# File 'app/models/bulk_action.rb', line 29

def run!
  # @TODO: guard this call for validation?

  # Queue Job
  BulkActionRunJob.perform_later(self)

  # Capture State
  # state_machine.transition_to!(:imported)
  # save
end

#state_machineObject



25
26
27
# File 'app/models/bulk_action.rb', line 25

def state_machine
  @state_machine ||= BulkActionStateMachine.new(self, transition_class: BulkActionTransition)
end