Class: Actor::Proxy
- Inherits:
- BasicObject
- Defined in:
- lib/actor/proxy.rb
Overview
The proxy class wraps an object and invokes all of its method using :send
Instance Method Summary collapse
-
#!=(other) ⇒ Object
Overrides the proxy equals to pass the equality check to the proxy target.
-
#==(other) ⇒ Object
Overrides the proxy equals to pass the equality check to the proxy target.
-
#__proxy_target ⇒ Object
Get the proxy target of this proxy.
-
#equal?(other) ⇒ Boolean
Overrides the proxy equals to pass the equality check to the proxy target.
-
#initialize(proxy_target) ⇒ Proxy
constructor
Create a new proxy.
-
#method_missing(name, *args, &block) ⇒ Object
Proxies the method call to the proxy target using :send.
Constructor Details
#initialize(proxy_target) ⇒ Proxy
Create a new proxy
-
Args:
-
proxy_target
: the instance to proxy
-
10 11 12 |
# File 'lib/actor/proxy.rb', line 10 def initialize proxy_target @proxy_target = proxy_target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Proxies the method call to the proxy target using :send
16 17 18 |
# File 'lib/actor/proxy.rb', line 16 def method_missing name, *args, &block @proxy_target.send name, *args, &block end |
Instance Method Details
#!=(other) ⇒ Object
Overrides the proxy equals to pass the equality check to the proxy target
36 37 38 |
# File 'lib/actor/proxy.rb', line 36 def != other @proxy_target != other end |
#==(other) ⇒ Object
Overrides the proxy equals to pass the equality check to the proxy target
30 31 32 |
# File 'lib/actor/proxy.rb', line 30 def == other @proxy_target == other end |
#__proxy_target ⇒ Object
Get the proxy target of this proxy
-
Returns: the proxy target
24 25 26 |
# File 'lib/actor/proxy.rb', line 24 def __proxy_target @proxy_target end |
#equal?(other) ⇒ Boolean
Overrides the proxy equals to pass the equality check to the proxy target
42 43 44 |
# File 'lib/actor/proxy.rb', line 42 def equal? other @proxy_target.equal? other end |