Created
March 18, 2010 05:57
-
-
Save rcarver/336091 to your computer and use it in GitHub Desktop.
what if resque had hooks for job performing?
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
def perform | |
if payload_class.respond_to?(:before_perform) | |
result = args ? payload_class.before_perform(*args) : payload_class.before_perform | |
return if result == false | |
end | |
begin | |
args ? payload_class.perform(*args) : payload_class.perform | |
if payload_class.respond_to?(:after_perform) | |
args ? payload_class.after_perform(*args) : payload_class.after_perform | |
end | |
rescue StandardError => e | |
if payload_class.respond_to?(:on_failure) | |
args ? payload_class.on_failure(e, *args) : payload_class.on_failure(e) | |
end | |
raise | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment