Class: Sidekiq::CurrentAttributes::Load
- Inherits:
-
Object
- Object
- Sidekiq::CurrentAttributes::Load
- Includes:
- ServerMiddleware
- Defined in:
- lib/sidekiq/middleware/current_attributes.rb
Instance Attribute Summary
Attributes included from ServerMiddleware
Instance Method Summary collapse
- #call(_, job, _, &block) ⇒ Object
-
#initialize(cattrs) ⇒ Load
constructor
A new instance of Load.
Methods included from ServerMiddleware
Constructor Details
#initialize(cattrs) ⇒ Load
Returns a new instance of Load.
44 45 46 |
# File 'lib/sidekiq/middleware/current_attributes.rb', line 44 def initialize(cattrs) @cattrs = cattrs end |
Instance Method Details
#call(_, job, _, &block) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sidekiq/middleware/current_attributes.rb', line 48 def call(_, job, _, &block) cattrs_to_reset = [] @cattrs.each do |(key, strklass)| if job.has_key?(key) constklass = strklass.constantize cattrs_to_reset << constklass job[key].each do |(attribute, value)| constklass.public_send(:"#{attribute}=", value) end end end yield ensure cattrs_to_reset.each(&:reset) end |