Class: LazyGraph::MissingValue
- Inherits:
-
Object
- Object
- LazyGraph::MissingValue
show all
- Defined in:
- lib/lazy_graph/missing_value.rb
Overview
Represents a value that is missing or undefined, allowing for graceful handling of method calls and JSON serialization even when the value is not present.
Constant Summary
collapse
- BLANK =
new('')
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MissingValue.
[View source]
9
|
# File 'lib/lazy_graph/missing_value.rb', line 9
def initialize(details) = @details = details
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
permalink
#method_missing(method, *args, &block) ⇒ Object
[View source]
26
27
28
29
30
31
|
# File 'lib/lazy_graph/missing_value.rb', line 26
def method_missing(method, *args, &block)
return super if method == :to_ary
return self if self == BLANK
MissingValue.new(:"#{details}##{method}#{args.any? ? :"(#{args.inspect[1...-1]})" : :''}")
end
|
Instance Attribute Details
Returns the value of attribute details.
7
8
9
|
# File 'lib/lazy_graph/missing_value.rb', line 7
def details
@details
end
|
Instance Method Details
permalink
#+(other) ⇒ Object
[View source]
15
|
# File 'lib/lazy_graph/missing_value.rb', line 15
def +(other) = other
|
permalink
#==(other) ⇒ Object
[View source]
20
21
22
23
24
|
# File 'lib/lazy_graph/missing_value.rb', line 20
def ==(other)
return true if other.nil?
super
end
|
[View source]
13
|
# File 'lib/lazy_graph/missing_value.rb', line 13
def as_json = nil
|
permalink
#coerce(other) ⇒ Object
[View source]
12
|
# File 'lib/lazy_graph/missing_value.rb', line 12
def coerce(other) = [self, other]
|
[View source]
11
|
# File 'lib/lazy_graph/missing_value.rb', line 11
def inspect = to_s
|
permalink
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
[View source]
16
|
# File 'lib/lazy_graph/missing_value.rb', line 16
def respond_to_missing?(_method_name, _include_private = false) = true
|
[View source]
18
|
# File 'lib/lazy_graph/missing_value.rb', line 18
def to_f = 0.0
|
[View source]
14
|
# File 'lib/lazy_graph/missing_value.rb', line 14
def to_h = nil
|
[View source]
17
|
# File 'lib/lazy_graph/missing_value.rb', line 17
def to_i = 0
|
[View source]
10
|
# File 'lib/lazy_graph/missing_value.rb', line 10
def to_s = "MISSING[#{@details}]"
|