Class: LazyObject
- Inherits:
-
BasicObject
- Defined in:
- lib/services/lazy_object.rb
Instance Method Summary
collapse
Constructor Details
#initialize(&callable) ⇒ LazyObject
Returns a new instance of LazyObject.
3
4
5
|
# File 'lib/services/lazy_object.rb', line 3
def initialize(&callable)
@callable = callable
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
15
16
17
|
# File 'lib/services/lazy_object.rb', line 15
def method_missing(method_name, *args, &block)
__target_object__.send(method_name, *args, &block)
end
|
Instance Method Details
#==(object) ⇒ Object
11
12
13
|
# File 'lib/services/lazy_object.rb', line 11
def ==(object)
__target_object__ == object
end
|
#__target_object__ ⇒ Object
7
8
9
|
# File 'lib/services/lazy_object.rb', line 7
def __target_object__
@__target_object__ ||= @callable.call
end
|