Skip to content

Commit 30ac31a

Browse files
committed
Update all to_json_hash_value methods to take optional options
1 parent 72bf456 commit 30ac31a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/protobuf/field/field_array.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ def to_hash_value
4949
# Return a hash-representation of the given values for this field type
5050
# that is safe to convert to JSON.
5151
# The value in this case would be an array.
52-
def to_json_hash_value
52+
def to_json_hash_value(options = {})
5353
if field.respond_to?(:json_encode)
5454
map do |value|
5555
field.json_encode(value)
5656
end
5757
else
5858
map do |value|
59-
value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value : value
59+
value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value(options) : value
6060
end
6161
end
6262
end

lib/protobuf/field/field_hash.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def to_hash_value
5858
# The value in this case would be the hash itself, right? Unfortunately
5959
# not because the values of the map could be messages themselves that we
6060
# need to transform.
61-
def to_json_hash_value
61+
def to_json_hash_value(options = {})
6262
if field.respond_to?(:json_encode)
6363
each_with_object({}) do |(key, value), hash|
6464
hash[key] = field.json_encode(value)
6565
end
6666
else
6767
each_with_object({}) do |(key, value), hash|
68-
hash[key] = value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value : value
68+
hash[key] = value.respond_to?(:to_json_hash_value) ? value.to_json_hash_value(options) : value
6969
end
7070
end
7171
end

0 commit comments

Comments
 (0)