[Ruby] Message.decode/encode: Add max_recursion_depth option (#9218)
* Message.decode/encode: Add max_recursion_depth option
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".
Fixes #1493
* Address review comments
Co-authored-by: Adam Cozzette <acozzette@google.com>
diff --git a/ruby/lib/google/protobuf.rb b/ruby/lib/google/protobuf.rb
index f939a4c..b7a6711 100644
--- a/ruby/lib/google/protobuf.rb
+++ b/ruby/lib/google/protobuf.rb
@@ -59,16 +59,16 @@
module Google
module Protobuf
- def self.encode(msg)
- msg.to_proto
+ def self.encode(msg, options = {})
+ msg.to_proto(options)
end
def self.encode_json(msg, options = {})
msg.to_json(options)
end
- def self.decode(klass, proto)
- klass.decode(proto)
+ def self.decode(klass, proto, options = {})
+ klass.decode(proto, options)
end
def self.decode_json(klass, json, options = {})