From 30ac31a898590b7a37689a191ed5f34b8ea9bea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Tue, 7 Jan 2020 11:44:40 +0000 Subject: [PATCH] Update all to_json_hash_value methods to take optional options --- lib/protobuf/field/field_array.rb | 4 ++-- lib/protobuf/field/field_hash.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/protobuf/field/field_array.rb b/lib/protobuf/field/field_array.rb index e4f2eb1a..eb1f29d9 100644 --- a/lib/protobuf/field/field_array.rb +++ b/lib/protobuf/field/field_array.rb @@ -49,14 +49,14 @@ def to_hash_value # Return a hash-representation of the given values for this field type # that is safe to convert to JSON. # The value in this case would be an array. - def to_json_hash_value + def to_json_hash_value(options = {}) if field.respond_to?(:json_encode) map do |value| field.json_encode(value) end else map do |value| - value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value : value + value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value(options) : value end end end diff --git a/lib/protobuf/field/field_hash.rb b/lib/protobuf/field/field_hash.rb index 36b26447..94eedbb9 100644 --- a/lib/protobuf/field/field_hash.rb +++ b/lib/protobuf/field/field_hash.rb @@ -58,14 +58,14 @@ def to_hash_value # The value in this case would be the hash itself, right? Unfortunately # not because the values of the map could be messages themselves that we # need to transform. - def to_json_hash_value + def to_json_hash_value(options = {}) if field.respond_to?(:json_encode) each_with_object({}) do |(key, value), hash| hash[key] = field.json_encode(value) end else each_with_object({}) do |(key, value), hash| - hash[key] = value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value : value + hash[key] = value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value(options) : value end end end