Sha256: cd728fe6bca536eea8f4b00cfe248bebc61ad0df6a15c74f4ba27296185a26ac

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

class Backgrounded::Handler::WorklingHandler
  def request(object, method, *args)
    if object.is_a? Class
      options = {
        :class => object.name,
        :class_method => true,
        :method => method,
        :params => args
      }
    else
      options = {
        :class => object.class.name,
        :class_method => false,
        :id => object.id,
        :method => method,
        :params => args
      }
    end
    BackgroundedWorker.async_perform options
  end

  class BackgroundedWorker < Workling::Base
    def perform(options = {})
      clazz = options[:class].constantize
      if options[:class_method]
        clazz.send(options[:method], *options[:params])
      else
        clazz.find(options[:id]).send(options[:method], *options[:params])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phene-backgrounded-0.6.2 lib/backgrounded/handler/workling_handler.rb