Class: Cel::MapType
Instance Attribute Summary collapse
-
#element_type ⇒ Object
Returns the value of attribute element_type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cast(value) ⇒ Object
- #get(attrib) ⇒ Object
-
#initialize(type_map) ⇒ MapType
constructor
A new instance of MapType.
Methods inherited from Type
Constructor Details
#initialize(type_map) ⇒ MapType
Returns a new instance of MapType.
74 75 76 77 78 |
# File 'lib/cel/ast/types.rb', line 74 def initialize(type_map) super(:map) @type_map = type_map @element_type = @type_map.empty? ? TYPES[:any] : @type_map.keys.sample.type end |
Instance Attribute Details
#element_type ⇒ Object
Returns the value of attribute element_type.
72 73 74 |
# File 'lib/cel/ast/types.rb', line 72 def element_type @element_type end |
Instance Method Details
#==(other) ⇒ Object
85 86 87 |
# File 'lib/cel/ast/types.rb', line 85 def ==(other) other == :map || super end |
#cast(value) ⇒ Object
89 90 91 |
# File 'lib/cel/ast/types.rb', line 89 def cast(value) Map.new(value) end |
#get(attrib) ⇒ Object
80 81 82 83 |
# File 'lib/cel/ast/types.rb', line 80 def get(attrib) _, value = @type_map.find { |k, _| k == attrib.to_s } value end |