Class: IbRubyProxy::Client::Client
- Inherits:
-
Object
- Object
- IbRubyProxy::Client::Client
- Defined in:
- lib/ib_ruby_proxy/client/client.rb
Overview
A client for interacting with the DRb service
If can be instantiated directly from the DRb service with Client.create_drb_ib_client
It offers the same interface than a Server::IbClientAdapter and, also, configures a CallbacksResponseHandler so that you can use Ruby blocks to capture callbacks invocations based on the semantics of the invoked methods.
Instance Attribute Summary collapse
-
#ib_client ⇒ Object
readonly
Returns the value of attribute ib_client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ib_client) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(ib_client) ⇒ Client
Returns a new instance of Client.
25 26 27 28 29 30 |
# File 'lib/ib_ruby_proxy/client/client.rb', line 25 def initialize(ib_client) @ib_client = ib_client @promises_by_request_id = {} @callbacks_response_handler = CallbacksResponseHandler.for_ib @ib_client.add_ib_callbacks_observer ResponseHandleObserver.new(@callbacks_response_handler) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object (private)
47 48 49 50 |
# File 'lib/ib_ruby_proxy/client/client.rb', line 47 def method_missing(method, *arguments, &block) @ib_client.public_send(method, *arguments, &block) @callbacks_response_handler.method_invoked method, *arguments, &block end |
Instance Attribute Details
#ib_client ⇒ Object (readonly)
Returns the value of attribute ib_client.
15 16 17 |
# File 'lib/ib_ruby_proxy/client/client.rb', line 15 def ib_client @ib_client end |
Class Method Details
.create_drb_ib_client(host:, port:) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ib_ruby_proxy/client/client.rb', line 33 def self.create_drb_ib_client(host:, port:) drb_ib_client = DRbObject.new(nil, "druby://#{host}:#{port}") DRb::DRbServer.verbose = true DRb.install_id_conv ::DRb::TimerIdConv.new 60 DRb.start_service drb_ib_client end |
.from_drb(host: 'localhost', port: 1992) ⇒ Client
20 21 22 |
# File 'lib/ib_ruby_proxy/client/client.rb', line 20 def self.from_drb(host: 'localhost', port: 1992) new(create_drb_ib_client(host: host, port: port)) end |