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
345
346
347
348
349
350
351
|
# File 'lib/cel/ast/elements.rb', line 345
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
326
327
328
329
330
331
|
# File 'lib/cel/ast/elements.rb', line 326
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
341
342
343
|
# File 'lib/cel/ast/elements.rb', line 341
def respond_to_missing?(meth, *args)
super || (@value && @value.keys.any? { |k| k.to_s == meth.to_s })
end
|
#to_ary ⇒ Object
333
334
335
|
# File 'lib/cel/ast/elements.rb', line 333
def to_ary
[self]
end
|
#to_ruby_type ⇒ Object
337
338
339
|
# File 'lib/cel/ast/elements.rb', line 337
def to_ruby_type
value.to_h { |*args| args.map(&:to_ruby_type) }
end
|