Class: JobDispatch::Client::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/job_dispatch/client/proxy.rb

Direct Known Subclasses

SynchronousProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, target, options = {}) ⇒ Proxy

Returns a new instance of Proxy.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/job_dispatch/client/proxy.rb', line 12

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



25
26
27
# File 'lib/job_dispatch/client/proxy.rb', line 25

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/job_dispatch/client/proxy.rb', line 10

def options
  @options
end

Instance Method Details

#queueObject



29
30
31
# File 'lib/job_dispatch/client/proxy.rb', line 29

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