Class: Sidekiq::CurrentAttributes::Load

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(cattrs) ⇒ Load

Returns a new instance of Load.



61
62
63
# File 'lib/sidekiq/middleware/current_attributes.rb', line 61

def initialize(cattrs)
  @cattrs = cattrs
end

Instance Method Details

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



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/sidekiq/middleware/current_attributes.rb', line 65

def call(_, job, _, &block)
  klass_attrs = {}

  @cattrs.each do |(key, strklass)|
    next unless job.has_key?(key)

    klass_attrs[strklass.constantize] = job[key]
  end

  wrap(klass_attrs.to_a, &block)
end