Class: Perennial::DelegateProxy

Inherits:
Proxy show all
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

#__proxy_target__

Instance Method Summary collapse

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/perennial/delegateable.rb', line 11

def respond_to?(method, inc_super = false)
  true
end