Created
July 31, 2011 22:41
-
-
Save softwaregravy/1117306 to your computer and use it in GitHub Desktop.
Pump custom values into hotoad
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
| class CustomJob | |
| def before(job) | |
| Delayed::Context.set(:handler, job.handler) | |
| Delayed::Context.set(:attempt, job.attempts + 1) | |
| Delayed::Context.set(:last_error, job.last_error) if job.last_error | |
| end | |
| def after(job) | |
| Delayed::Context.clear | |
| end | |
| def perform | |
| #blah blah blah | |
| end | |
| end |
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 Delayed | |
| module Context | |
| def self.set(key, value) | |
| Thread.current[:delayed_job_context] ||= Hash.new | |
| Thread.current[:delayed_job_context][key] = value | |
| end | |
| def self.get_all | |
| Thread.current[:delayed_job_context] || {} | |
| end | |
| def self.clear | |
| Thread.current[:delayed_job_context] = Hash.new | |
| end | |
| end | |
| end |
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 HoptoadNotifier | |
| class Notice | |
| alias _old_find_session_data find_session_data | |
| def find_session_data | |
| _old_find_session_data | |
| self.session_data.merge!(Delayed::Context.get_all) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment