Created
December 18, 2014 13:01
-
-
Save dolzenko/b101562279356474d610 to your computer and use it in GitHub Desktop.
Make originator of change tracked with paper_trail available in Sidekiq background workers
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 Acme | |
module Sidekiq | |
module PaperTrailMiddleware | |
class Client | |
# @param [Object] | |
# @param [Hash] job | |
def call(_, job, *) | |
job['whodunnit'] = ::PaperTrail.whodunnit | |
yield | |
end | |
end | |
class Server | |
# @param [Object] | |
# @param [Hash] job | |
def call(_, job, *) | |
unless ::PaperTrail.whodunnit.present? | |
::PaperTrail.whodunnit = job['whodunnit'] | |
end | |
yield | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment