Sha256: 1f1c5e73da93626dfbda11c5dec4f2a2ffc072d8fb63a22ae3e21872310984fb

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

# encoding: UTF-8

module JobDispatch

  # This is a simple class for making synchronous calls to the Job Queue dispatcher.
  class Client

    class Proxy

      attr :options

      def initialize(client, target, options={})
        @client = client
        @target = case target
                    when Class
                      target.to_s
                    when String
                      target
                    else
                      raise NotImplementedError, "Don't yet know how to serialize an object instance as a target"
                  end
        @options = options
      end

      def method_missing(method, *args)
        @client.enqueue(queue: queue, target: @target, method: method.to_s, parameters: args)
      end

      def queue
        @options[:queue] || :default
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
job_dispatch-0.2.0 lib/job_dispatch/client/proxy.rb
job_dispatch-0.1.0 lib/job_dispatch/client/proxy.rb
job_dispatch-0.0.2 lib/job_dispatch/client/proxy.rb
job_dispatch-0.0.1 lib/job_dispatch/client/proxy.rb