class ResqueAsync::Enqueuers::ClassEnqueuer

Attributes

host_class[R]
priority[R]

Public Class Methods

new(host_class, priority) click to toggle source
# File lib/resque-async/enqueuers.rb, line 8
def initialize(host_class, priority)
  @host_class = host_class
  @priority = priority
end

Public Instance Methods

method_missing(methId, *args) click to toggle source
Calls superclass method
# File lib/resque-async/enqueuers.rb, line 13
def method_missing(methId, *args)
  # call super unless the host responds to the method
  return super unless @host_class.respond_to?(methId.id2name.to_sym)

  case @priority
    when Class
      worker = @priority
    when :high
      worker = Workers::HighPriorityClassMethod
    when :medium
      worker = Workers::MediumPriorityClassMethod
    when :low
      worker = Workers::LowPriorityClassMethod
    when :realtime
      return args.empty? ? @host_class.send(methId.id2name) : @host_class.send(methId.id2name, *args)
    else
      raise StandardError.new("Unknown priority '#{@priority}'")
  end
  # enqueue
  Resque.enqueue(worker, @host_class.name, methId.id2name, args)
end