Created
August 6, 2012 22:16
-
-
Save elight/3278949 to your computer and use it in GitHub Desktop.
Partially elided patch to Resque to mitigate monkey patching need to support extra hooks
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
module Resque | |
def self.hook_responders | |
@hook_responders ||= [self] | |
@hook_responders | |
end | |
def self.register_hook_responder(responder) | |
hook_responsers << responder | |
end | |
class Worker | |
# Runs a named hook, passing along any arguments. | |
def run_hook(name, *args) | |
hook = Resque.hook_responders.find { |r| r.send(name) } | |
return unless hook | |
# ... | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment