Skip to content

Commit

Permalink
making #on_permanent_failure optionally take the job record as a para…
Browse files Browse the repository at this point in the history
…meter (for better email notifications)
  • Loading branch information
nruth authored and bkeepers committed Jul 21, 2010
1 parent 71fbb4f commit ce10066
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/delayed/worker.rb
Expand Up @@ -142,7 +142,12 @@ def reschedule(job, time = nil)

if job.payload_object.respond_to? :on_permanent_failure
say "Running on_permanent_failure hook"
job.payload_object.on_permanent_failure
failure_method = job.payload_object.method(:on_permanent_failure)
if failure_method.arity == 1
failure_method.call(job)
else
failure_method.call
end
end

self.class.destroy_failed_jobs ? job.destroy : job.update_attributes(:failed_at => Delayed::Job.db_time_now)
Expand Down

0 comments on commit ce10066

Please sign in to comment.