Skip to content

Instantly share code, notes, and snippets.

@elight
Created August 6, 2012 22:16
Show Gist options
  • Save elight/3278949 to your computer and use it in GitHub Desktop.
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
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