Class: LazyMethods::LazyProxy
Overview
:nodoc:
Constant Summary
Constants inherited from Proxy
Instance Method Summary collapse
-
#__proxy_loaded__ ⇒ Object
Helper method that indicates if the proxy has loaded the original method results yet.
-
#__proxy_result__ ⇒ Object
Get the result of the original method call.
-
#initialize(&block) ⇒ LazyProxy
constructor
A new instance of LazyProxy.
Methods inherited from Proxy
Constructor Details
#initialize(&block) ⇒ LazyProxy
Returns a new instance of LazyProxy.
96 97 98 |
# File 'lib/lazy_methods.rb', line 96 def initialize(&block) @method_call = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LazyMethods::Proxy
Instance Method Details
#__proxy_loaded__ ⇒ Object
Helper method that indicates if the proxy has loaded the original method results yet.
107 108 109 |
# File 'lib/lazy_methods.rb', line 107 def __proxy_loaded__ !!defined?(@proxy_result) end |
#__proxy_result__ ⇒ Object
Get the result of the original method call. The original method must only be called once.
101 102 103 104 |
# File 'lib/lazy_methods.rb', line 101 def __proxy_result__ @proxy_result = @method_call.call unless defined?(@proxy_result) @proxy_result end |