Class: Delayed::Backend::Mongoid::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/app/models/delayed_job.rb

Overview

Extend the Mongoid delayed job to add additional methods

Instance Method Summary collapse

Instance Method Details

#display_nameObject

Display name for the job



20
21
22
23
24
# File 'lib/app/models/delayed_job.rb', line 20

def display_name
  payload_object.job_data['job_class']
rescue StandardError
  name
end

#failed_argsObject

Return the failed arguments out of the YAML



63
64
65
66
67
# File 'lib/app/models/delayed_job.rb', line 63

def failed_args
  failed_yaml.args
rescue StandardError => error
  "Unknown args: #{error.message}"
end

#failed_method_nameObject

Return the failed method out of the YAML



54
55
56
57
58
# File 'lib/app/models/delayed_job.rb', line 54

def failed_method_name
  failed_yaml.method_name
rescue StandardError => error
  "Unknown method_name: #{error.message}"
end

#failed_objectObject

Return the failed object out of the YAML



45
46
47
48
49
# File 'lib/app/models/delayed_job.rb', line 45

def failed_object
  failed_yaml.object
rescue StandardError => error
  "Unknown object: #{error.message}"
end

#failed_yamlObject

Return the failed YAML



72
73
74
75
76
# File 'lib/app/models/delayed_job.rb', line 72

def failed_yaml
  @failed_yaml = YAML.load(handler)
rescue StandardError
  ''
end

#job_payloadObject

Safely get the payload object



29
30
31
32
33
# File 'lib/app/models/delayed_job.rb', line 29

def job_payload
  payload_object.inspect
rescue StandardError => error
  "Unable to retrieve payload: #{error.message}"
end

#resubmitObject

Resubmit the job for processing



38
39
40
# File 'lib/app/models/delayed_job.rb', line 38

def resubmit
  set locked_at: nil, locked_by: nil, failed_at: nil, last_error: nil, run_at: Time.now.utc
end

#status_descriptionObject

Helper to describe the status of the job



11
12
13
14
15
# File 'lib/app/models/delayed_job.rb', line 11

def status_description
  return 'Failed' if failed?

  locked_by.presence || "Scheduled (#{attempts})"
end