lib/cel/ast/elements/protobuf.rb in cel-0.2.1 vs lib/cel/ast/elements/protobuf.rb in cel-0.2.2
- old
+ new
@@ -58,12 +58,18 @@
key = value.keys.first
value = value.fetch(key, value)
- value = Number.new(:double, value) if key == "number_value"
-
- value
+ value = case key
+ when "null_value"
+ Null.new if value.zero?
+ when "number_value"
+ value = -value.operands.first if value.is_a?(Operation) && value.op == "-" && value.unary?
+ Number.new(:double, value)
+ else
+ value
+ end
when "BoolValue", "google.protobuf.BoolValue"
value = value.nil? ? Bool.new(false) : value[Identifier.new("value")]
when "BytesValue", "google.protobuf.BytesValue"
value = value[Identifier.new("value")]
when "DoubleValue", "google.protobuf.DoubleValue",