Browse files

making #on_permanent_failure optionally take the job record as a para…

…meter (for better email notifications)
  • Loading branch information...
1 parent 71fbb4f commit ce10066d5fcadfc19046e826c12db05ab313709e @nruth nruth committed with bkeepers Jul 7, 2010
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/delayed/worker.rb
View
7 lib/delayed/worker.rb
@@ -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)

0 comments on commit ce10066

Please sign in to comment.