Class: Sidekiq::CurrentAttributes::Save

Inherits:
Object
  • Object
show all
Includes:
ServerMiddleware
Defined in:
lib/sidekiq/middleware/current_attributes.rb

Instance Attribute Summary

Attributes included from ServerMiddleware

#config

Instance Method Summary collapse

Methods included from ServerMiddleware

#logger, #redis, #redis_pool

Constructor Details

#initialize(cattr) ⇒ Save

Returns a new instance of Save.



20
21
22
# File 'lib/sidekiq/middleware/current_attributes.rb', line 20

def initialize(cattr)
  @klass = cattr
end

Instance Method Details

#call(_, job, _, _) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/sidekiq/middleware/current_attributes.rb', line 24

def call(_, job, _, _)
  attrs = @klass.attributes
  if job.has_key?("cattr")
    job["cattr"].merge!(attrs)
  else
    job["cattr"] = attrs
  end
  yield
end