Module: RocketJob::Plugins::Job::Persistence

Extended by:
ActiveSupport::Concern
Included in:
Job
Defined in:
lib/rocket_job/plugins/job/persistence.rb

Overview

Prevent more than one instance of this job class from running at a time

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#reloadObject

Set in-memory job to complete if ‘destroy_on_complete` and the job has been destroyed



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rocket_job/plugins/job/persistence.rb', line 74

def reload
  return super unless destroy_on_complete

  begin
    super
  rescue ::Mongoid::Errors::DocumentNotFound
    unless completed?
      self.state = :completed
      rocket_job_set_completed_at
      rocket_job_mark_complete
    end
    self
  end
end