class Sidekiq::CurrentAttributes::Load
def call(_, job, _, &block)
def call(_, job, _, &block) klass_attrs = {} @cattrs.each do |(key, strklass)| next unless job.has_key?(key) klass_attrs[strklass.constantize] = Serializer.deserialize(job[key]).to_h end wrap(klass_attrs.to_a, &block) end
def initialize(cattrs)
def initialize(cattrs) @cattrs = cattrs end
def wrap(klass_attrs, &block)
def wrap(klass_attrs, &block) klass, attrs = klass_attrs.shift return block.call unless klass retried = false begin set_succeeded = false klass.set(attrs) do set_succeeded = true wrap(klass_attrs, &block) end rescue NoMethodError # Don't retry if the no method error didn't come from current attributes raise if retried || set_succeeded # It is possible that the `CurrentAttributes` definition # was changed before the job started processing. attrs = attrs.select { |attr| klass.respond_to?(attr) } retried = true retry end end