Class: Perennial::DelegateProxy
- Defined in:
- lib/perennial/delegateable.rb
Overview
Objective-C / Cocoa style ‘delegates’. Essentially proxies which dispatch only when an object responds to the method.
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#initialize(t) ⇒ DelegateProxy
constructor
A new instance of DelegateProxy.
- #respond_to?(method, inc_super = false) ⇒ Boolean
Constructor Details
#initialize(t) ⇒ DelegateProxy
Returns a new instance of DelegateProxy.
7 8 9 |
# File 'lib/perennial/delegateable.rb', line 7 def initialize(t) @__proxy_target__ = t end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (protected)
17 18 19 |
# File 'lib/perennial/delegateable.rb', line 17 def method_missing(method, *args, &blk) @__proxy_target__.send(method, *args, &blk) if @__proxy_target__.respond_to?(method) end |
Instance Method Details
#respond_to?(method, inc_super = false) ⇒ Boolean
11 12 13 |
# File 'lib/perennial/delegateable.rb', line 11 def respond_to?(method, inc_super = false) true end |