Class: Grape::Util::Lazy::Object
- Inherits:
-
BasicObject
- Defined in:
- lib/grape/util/lazy/object.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(&callable) ⇒ Object
Returns a new instance of Object.
11
12
13
|
# File 'lib/grape/util/lazy/object.rb', line 11
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
31
32
33
34
35
36
37
|
# File 'lib/grape/util/lazy/object.rb', line 31
def method_missing(method_name, *args, &block)
if __target_object__.respond_to?(method_name)
__target_object__.send(method_name, *args, &block)
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute callable.
9
10
11
|
# File 'lib/grape/util/lazy/object.rb', line 9
def callable
@callable
end
|
Instance Method Details
27
28
29
|
# File 'lib/grape/util/lazy/object.rb', line 27
def !
!__target_object__
end
|
#!=(other) ⇒ Object
23
24
25
|
# File 'lib/grape/util/lazy/object.rb', line 23
def !=(other)
__target_object__ != other
end
|
#==(other) ⇒ Object
19
20
21
|
# File 'lib/grape/util/lazy/object.rb', line 19
def ==(other)
__target_object__ == other
end
|
#__target_object__ ⇒ Object
15
16
17
|
# File 'lib/grape/util/lazy/object.rb', line 15
def __target_object__
@__target_object__ ||= callable.call
end
|
#respond_to_missing?(method_name, include_priv = false) ⇒ Boolean
39
40
41
|
# File 'lib/grape/util/lazy/object.rb', line 39
def respond_to_missing?(method_name, include_priv = false)
__target_object__.respond_to?(method_name, include_priv)
end
|