class Sidekiq::CurrentAttributes::Save
Public Class Methods
new(cattrs)
click to toggle source
# File lib/sidekiq/middleware/current_attributes.rb, line 26 def initialize(cattrs) @cattrs = cattrs end
Public Instance Methods
call(_, job, _, _) { || ... }
click to toggle source
# File lib/sidekiq/middleware/current_attributes.rb, line 30 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 if attrs.any? # Older rails has a bug that `CurrentAttributes#attributes` always returns # the same hash instance. We need to dup it to avoid being accidentally mutated. job[key] = if returns_same_object? attrs.dup else attrs end end end end yield end
Private Instance Methods
returns_same_object?()
click to toggle source
# File lib/sidekiq/middleware/current_attributes.rb, line 52 def returns_same_object? ActiveSupport::VERSION::MAJOR < 8 || (ActiveSupport::VERSION::MAJOR == 8 && ActiveSupport::VERSION::MINOR == 0) end