Class: GScholar::Utils::LazyProxy
- Inherits:
- BasicObject
- Defined in:
- lib/gscholar/utils/lazy_proxy.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ LazyProxy
constructor
A new instance of LazyProxy.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ LazyProxy
Returns a new instance of LazyProxy.
4 5 6 |
# File 'lib/gscholar/utils/lazy_proxy.rb', line 4 def initialize(&block) @initializer = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
8 9 10 11 |
# File 'lib/gscholar/utils/lazy_proxy.rb', line 8 def method_missing(method, *args, &block) @obj ||= @initializer.call @obj.send(method, *args, &block) end |