Skip to content

Instantly share code, notes, and snippets.

@ckdake
Created April 7, 2011 18:06
Show Gist options
  • Save ckdake/908339 to your computer and use it in GitHub Desktop.
Save ckdake/908339 to your computer and use it in GitHub Desktop.
# Unfortunately the Rails 2 version of DJ doesn't support before/after hooks. This hacks those in
# Stick this in an initalizer, and then any before(job) and after(job) methods in your Job classes will get called
module Delayed
module Backend
module ActiveRecord
class Job < ::ActiveRecord::Base
def invoke_job
payload_object.before(self) if payload_object.respond_to?('before')
payload_object.perform
payload_object.after(self) if payload_object.respond_to?('after')
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment