Class: AcidicJob::Execution

Inherits:
Record
  • Object
show all
Defined in:
app/models/acidic_job/execution.rb

Instance Method Summary collapse

Instance Method Details

#contextObject



27
28
29
# File 'app/models/acidic_job/execution.rb', line 27

def context
  @context ||= Context.new(self)
end

#deserialized_jobObject



35
36
37
38
39
# File 'app/models/acidic_job/execution.rb', line 35

def deserialized_job
  serialized_job["job_class"].constantize.new.tap do |job|
    job.deserialize(serialized_job)
  end
end

#enqueue_jobObject



45
46
47
48
# File 'app/models/acidic_job/execution.rb', line 45

def enqueue_job
  deserialized_job.enqueue
  true
end

#finished?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/acidic_job/execution.rb', line 31

def finished?
  recover_to.to_s == FINISHED_RECOVERY_POINT
end

#raw_argumentsObject



41
42
43
# File 'app/models/acidic_job/execution.rb', line 41

def raw_arguments
  JSON.parse(serialized_job_before_type_cast)["arguments"]
end

#record!(step:, action:, timestamp:, **kwargs) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'app/models/acidic_job/execution.rb', line 16

def record!(step:, action:, timestamp:, **kwargs)
  AcidicJob.instrument(:record_entry, step: step, action: action, timestamp: timestamp, data: kwargs) do
    entries.create!(
      step: step,
      action: action,
      timestamp: timestamp,
      data: kwargs.stringify_keys!
    )
  end
end