Class: VirtualProxy::Proxy
- Inherits:
-
Delegator
- Object
- Delegator
- VirtualProxy::Proxy
- Defined in:
- lib/virtual_proxy/proxy.rb
Overview
Forward messages to a lazily-evaluated subject
Instance Method Summary collapse
- #__getobj__ ⇒ Object
- #__setobj__(&block) ⇒ Object
-
#initialize(&block) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(&block) ⇒ Proxy
Returns a new instance of Proxy.
4 5 6 |
# File 'lib/virtual_proxy/proxy.rb', line 4 def initialize(&block) @block = block end |
Instance Method Details
#__getobj__ ⇒ Object
8 9 10 |
# File 'lib/virtual_proxy/proxy.rb', line 8 def __getobj__ @__getobj__ ||= @block.call end |
#__setobj__(&block) ⇒ Object
12 13 14 15 |
# File 'lib/virtual_proxy/proxy.rb', line 12 def __setobj__(&block) @block = block @__getobj__ = nil end |