Class: Cel::Map
Instance Attribute Summary
Attributes inherited from Literal
#type, #value
Instance Method Summary
collapse
Methods inherited from Literal
to_cel_type
Constructor Details
#initialize(value) ⇒ Map
Returns a new instance of Map.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
325
326
327
328
329
330
331
|
# File 'lib/cel/ast/elements.rb', line 325
def method_missing(meth, *args)
return super unless @value
key = @value.keys.find { |k| k.to_s == meth.to_s } or return super
@value[key]
end
|
Instance Method Details
#==(other) ⇒ Object
310
311
312
313
314
315
|
# File 'lib/cel/ast/elements.rb', line 310
def ==(other)
super || (
other.respond_to?(:to_hash) &&
@value.zip(other).all? { |(x1, y1), (x2, y2)| x1 == x2 && y1 == y2 }
)
end
|
#respond_to_missing?(meth, *args) ⇒ Boolean
321
322
323
|
# File 'lib/cel/ast/elements.rb', line 321
def respond_to_missing?(meth, *args)
super || (@value && @value.keys.any? { |k| k.to_s == meth.to_s })
end
|
#to_ary ⇒ Object
317
318
319
|
# File 'lib/cel/ast/elements.rb', line 317
def to_ary
[self]
end
|