Class: IbRubyProxy::Server::IbClientAdapter
- Inherits:
-
Object
- Object
- IbRubyProxy::Server::IbClientAdapter
- Extended by:
- Util::StringUtils
- Defined in:
- lib/ib_ruby_proxy/server/ib_client_adapter.rb
Overview
This is the Ruby representation of the IB Java EClient
class. It adapts ruby invocations and arguments to invoke the corresponding Java API methods.
It is the object DRb clients get when connecting to the proxy service.
Mimicking how the Java API works, it collaborates with an IbWrapperAdapter that corresponds with an EWrapper
in the Java world. It works by observing callbacks in this wrapper.
The usage of observers as a communication mechanism is because it is supported by DRb and, being DRb a standard implemented in JRuby, enables communicating Ruby and JRuby. If supporting other rubies was not required this level of indirection would be unnecessary.
Instance Attribute Summary collapse
-
#ib_client ⇒ Object
readonly
Returns the value of attribute ib_client.
-
#ib_wrapper_adapter ⇒ Object
readonly
Returns the value of attribute ib_wrapper_adapter.
Class Method Summary collapse
Instance Method Summary collapse
- #add_ib_callbacks_observer(ib_callbacks_observer) ⇒ Object
-
#initialize(ib_client, ib_wrapper_adapter) ⇒ IbClientAdapter
constructor
A new instance of IbClientAdapter.
Methods included from Util::StringUtils
Constructor Details
#initialize(ib_client, ib_wrapper_adapter) ⇒ IbClientAdapter
Returns a new instance of IbClientAdapter.
24 25 26 27 |
# File 'lib/ib_ruby_proxy/server/ib_client_adapter.rb', line 24 def initialize(ib_client, ib_wrapper_adapter) @ib_client = ib_client @ib_wrapper_adapter = ib_wrapper_adapter end |
Instance Attribute Details
#ib_client ⇒ Object (readonly)
Returns the value of attribute ib_client.
20 21 22 |
# File 'lib/ib_ruby_proxy/server/ib_client_adapter.rb', line 20 def ib_client @ib_client end |
#ib_wrapper_adapter ⇒ Object (readonly)
Returns the value of attribute ib_wrapper_adapter.
20 21 22 |
# File 'lib/ib_ruby_proxy/server/ib_client_adapter.rb', line 20 def ib_wrapper_adapter @ib_wrapper_adapter end |
Class Method Details
.define_ruby_method_for(java_method) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ib_ruby_proxy/server/ib_client_adapter.rb', line 35 def self.define_ruby_method_for(java_method) ruby_method_name = to_underscore(java_method.name) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{ruby_method_name}(*arguments) ib_arguments = arguments.collect(&:to_ib) @ib_client.#{java_method.name} *ib_arguments end RUBY end |
Instance Method Details
#add_ib_callbacks_observer(ib_callbacks_observer) ⇒ Object
30 31 32 |
# File 'lib/ib_ruby_proxy/server/ib_client_adapter.rb', line 30 def add_ib_callbacks_observer(ib_callbacks_observer) ib_wrapper_adapter.add_observer(ib_callbacks_observer) end |