Created
April 7, 2011 18:06
-
-
Save ckdake/908339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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