Class: QRPC::Client
- Inherits:
-
Object
- Object
- QRPC::Client
- Defined in:
- lib/qrpc/client.rb,
lib/qrpc/client/job.rb,
lib/qrpc/client/exception.rb,
lib/qrpc/client/dispatcher.rb
Overview
Note:
Since 0.3.0, all non-system methods was moved to the Dispatcher module for maximal avoiding the user API name conflicts.
Queue RPC client.
Defined Under Namespace
Classes: Dispatcher, Exception, Job
Instance Attribute Summary collapse
-
#dispatcher ⇒ Dispatcher
Holds working dispatcher.
Instance Method Summary collapse
-
#initialize(locator, generator = QRPC::default_generator, protocol = QRPC::default_protocol) ⇒ Client
constructor
Constructor.
-
#method_missing(name, *args, &block) ⇒ Object
Handles call to RPC.
Constructor Details
#initialize(locator, generator = QRPC::default_generator, protocol = QRPC::default_protocol) ⇒ Client
Constructor.
43 44 45 |
# File 'lib/qrpc/client.rb', line 43 def initialize(locator, generator = QRPC::default_generator, protocol = QRPC::default_protocol) @dispatcher = QRPC::Client::Dispatcher::new(locator, generator, protocol) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Handles call to RPC. (*********)
Be warn, arguments will be serialized to JSON, so they should be serializable nativelly or implement #to_s
or #to_json
method.
59 60 61 |
# File 'lib/qrpc/client.rb', line 59 def method_missing(name, *args, &block) @dispatcher.put(@dispatcher.create_job(name, args, &block)) end |
Instance Attribute Details
#dispatcher ⇒ Dispatcher
Holds working dispatcher.
32 33 34 |
# File 'lib/qrpc/client.rb', line 32 def dispatcher @dispatcher end |