Class: Async::Bus::Protocol::Proxy
- Inherits:
- BasicObject
- Defined in:
- lib/async/bus/protocol/proxy.rb
Overview
A proxy object that forwards method calls to a remote object.
We must be extremely careful not to invoke any methods on the proxy object that would recursively call the proxy object.
Instance Method Summary collapse
-
#! ⇒ Object
Logical negation operator.
-
#!=(object) ⇒ Object
Inequality operator.
-
#==(object) ⇒ Object
Equality operator.
-
#__connection__ ⇒ Object
Get the connection to the remote object.
-
#__name__ ⇒ Object
Get the name of the remote object.
-
#initialize(connection, name) ⇒ Proxy
constructor
Create a new proxy object.
-
#inspect ⇒ Object
Return a string representation of the proxy.
-
#method_missing(*arguments, **options, &block) ⇒ Object
Forward method calls to the remote object.
-
#respond_to?(name, include_all = false) ⇒ Boolean
Check if the remote object responds to a method.
Constructor Details
#initialize(connection, name) ⇒ Proxy
Create a new proxy object.
17 18 19 20 |
# File 'lib/async/bus/protocol/proxy.rb', line 17 def initialize(connection, name) @connection = connection @name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*arguments, **options, &block) ⇒ Object
Forward method calls to the remote object.
59 60 61 |
# File 'lib/async/bus/protocol/proxy.rb', line 59 def method_missing(*arguments, **, &block) @connection.invoke(@name, arguments, , &block) end |
Instance Method Details
#! ⇒ Object
Logical negation operator.
36 37 38 |
# File 'lib/async/bus/protocol/proxy.rb', line 36 def ! @connection.invoke(@name, [:!]) end |
#!=(object) ⇒ Object
Inequality operator.
50 51 52 |
# File 'lib/async/bus/protocol/proxy.rb', line 50 def != object @connection.invoke(@name, [:!=, object]) end |
#==(object) ⇒ Object
Equality operator.
43 44 45 |
# File 'lib/async/bus/protocol/proxy.rb', line 43 def == object @connection.invoke(@name, [:==, object]) end |
#__connection__ ⇒ Object
Get the connection to the remote object.
24 25 26 |
# File 'lib/async/bus/protocol/proxy.rb', line 24 def __connection__ @connection end |
#__name__ ⇒ Object
Get the name of the remote object.
30 31 32 |
# File 'lib/async/bus/protocol/proxy.rb', line 30 def __name__ @name end |
#inspect ⇒ Object
Return a string representation of the proxy.
73 74 75 |
# File 'lib/async/bus/protocol/proxy.rb', line 73 def inspect "#<proxy #{@name}>" end |
#respond_to?(name, include_all = false) ⇒ Boolean
Check if the remote object responds to a method.
67 68 69 |
# File 'lib/async/bus/protocol/proxy.rb', line 67 def respond_to?(name, include_all = false) @connection.invoke(@name, [:respond_to?, name, include_all]) end |