Sha256: a5deaeb4572159acf011685d8a0b18e4d7a622a2f1fcc774e7737332f192f210

Contents?: true

Size: 576 Bytes

Versions: 4

Compression:

Stored size: 576 Bytes

Contents

require 'resque'

module Backgrounded
  module Handler
    #enque requests in resque
    class ResqueHandler
      DEFAULT_QUEUE = 'backgrounded'
      @@queue = DEFAULT_QUEUE

      def request(object, method, *args)
        @@queue = object.backgrounded_options[method.to_sym][:queue] || DEFAULT_QUEUE
        Resque.enqueue(ResqueHandler, object.class.name, object.id, method, *args)
      end
      def self.queue
        @@queue
      end
      def self.perform(clazz, id, method, *args)
        clazz.constantize.find(id).send(method, *args)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
backgrounded-0.6.2 lib/backgrounded/handler/resque_handler.rb
backgrounded-0.6.1 lib/backgrounded/handler/resque_handler.rb
backgrounded-0.6.0 lib/backgrounded/handler/resque_handler.rb
backgrounded-0.5.0 lib/backgrounded/handler/resque_handler.rb