Class: BigRecordDriver::Client
- Inherits:
-
Object
- Object
- BigRecordDriver::Client
- Defined in:
- lib/big_record_driver/client.rb
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Client
constructor
:nodoc:.
-
#method_missing(method, *args) ⇒ Object
Delegate the methods to the server.
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(config = {}) ⇒ Client
:nodoc:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/big_record_driver/client.rb', line 9 def initialize(config={}) # :nodoc: config = config.symbolize_keys config[:drb_host] ||= '127.0.0.1' config[:drb_port] ||= 40000 @config = config DRb.start_service('druby://127.0.0.1:0') begin @server = DRbObject.new(nil, "druby://#{@config[:drb_host]}:#{@config[:drb_port]}") rescue DRb::DRbConnError raise ConnectionError, "Failed to connect to the DRb server (jruby) " + "at #{@config[:drb_host]}:#{@config[:drb_port]}." end @server.configure(@config) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Delegate the methods to the server
27 28 29 |
# File 'lib/big_record_driver/client.rb', line 27 def method_missing(method, *args) @server.send(method, *args) end |
Instance Method Details
#respond_to?(method) ⇒ Boolean
31 32 33 |
# File 'lib/big_record_driver/client.rb', line 31 def respond_to?(method) super end |