lib/cel/ast/elements.rb in cel-0.1.0 vs lib/cel/ast/elements.rb in cel-0.1.1

- old
+ new

@@ -25,13 +25,13 @@ class Message < SimpleDelegator attr_reader :type, :struct def initialize(type, struct) @struct = Struct.new(*struct.keys.map(&:to_sym)).new(*struct.values) - @type = type.is_a?(Type) ? type : MapType.new(struct.map do |k, v| + @type = type.is_a?(Type) ? type : MapType.new(struct.to_h do |k, v| [Literal.to_cel_type(k), Literal.to_cel_type(v)] - end.to_h) + end) super(@struct) end def field?(key) !@type.get(key).nil? @@ -174,11 +174,11 @@ end LOGICAL_OPERATORS.each do |op| class_eval(<<-OUT, __FILE__, __LINE__ + 1) def #{op}(other) - Bool.new(super) + other.is_a?(Cel::Literal) ? Bool.new(super) : super end OUT end %i[+ -].each do |op| @@ -229,12 +229,12 @@ end end class Map < Literal def initialize(value) - value = value.map do |k, v| + value = value.to_h do |k, v| [Literal.to_cel_type(k), Literal.to_cel_type(v)] - end.to_h + end super(MapType.new(value), value) check end def ==(other)