Skip to content

Instantly share code, notes, and snippets.

@dolzenko
Created December 18, 2014 13:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dolzenko/b101562279356474d610 to your computer and use it in GitHub Desktop.
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
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