class Sidekiq::Delayed::Performer

Public Class Methods

create(target, queue, *args) click to toggle source
# File lib/sidekiq/delayed/performer.rb, line 18
def create(target, queue, *args)
  options = { class: self, args: enqueue_payload(target, *args) }
  options[:queue] = queue if queue
  client_push options
end
enqueue_payload(target, *args) click to toggle source
# File lib/sidekiq/delayed/performer.rb, line 24
def enqueue_payload(target, *args)
  method = args.shift()
  options = {
    class: target.class.to_s,
    id: target.id.to_s,
    method: method,
    args: args,
  }
  options[:scope] = target.scope && !target.scope.is_a?(String) ? target.scope.id.to_s : target.scope
  options[:timestamp] = target.timestamp if target.respond_to? :timestamp

  [YAML.dump(options)]
end

Public Instance Methods

perform(yml) click to toggle source
# File lib/sidekiq/delayed/performer.rb, line 6
def perform(yml)
  options = YAML.load yml
  model = options[:class].constantize.unscoped.where(id: options[:id]).first
  return unless model.present?

  model.scope = options.delete(:scope)
  model.timestamp = options.delete(:timestamp)

  model.send options[:method], *options[:args]
end