Class: Sidekiq::CurrentAttributes::Save
- Inherits:
-
Object
- Object
- Sidekiq::CurrentAttributes::Save
- Includes:
- ServerMiddleware
- Defined in:
- lib/sidekiq/middleware/current_attributes.rb
Instance Attribute Summary
Attributes included from ServerMiddleware
Instance Method Summary collapse
- #call(_, job, _, _) ⇒ Object
-
#initialize(cattrs) ⇒ Save
constructor
A new instance of Save.
Methods included from ServerMiddleware
Constructor Details
#initialize(cattrs) ⇒ Save
Returns a new instance of Save.
29 30 31 |
# File 'lib/sidekiq/middleware/current_attributes.rb', line 29 def initialize(cattrs) @cattrs = cattrs end |
Instance Method Details
#call(_, job, _, _) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekiq/middleware/current_attributes.rb', line 33 def call(_, job, _, _) @cattrs.each do |(key, strklass)| if !job.has_key?(key) attrs = strklass.constantize.attributes # Retries can push the job N times, we don't # want retries to reset cattr. #5692, #5090 job[key] = Serializer.serialize(attrs) if attrs.any? end end yield end |