From 90f986a5fd2f5e8bda3f338c67304ef96feee446 Mon Sep 17 00:00:00 2001 From: MQuy Date: Tue, 14 Feb 2023 20:11:15 +0100 Subject: [PATCH] chore(6178): rename enums_as_integers to format_enums_as_integers --- ruby/ext/google/protobuf_c/message.c | 2 +- .../main/java/com/google/protobuf/jruby/RubyMessage.java | 6 +++--- ruby/tests/encode_decode_test.rb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index bea488315c7b..569d81734bc4 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -1165,7 +1165,7 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) { options |= upb_JsonEncode_EmitDefaults; } - if (RTEST(rb_hash_lookup2(hash_args, ID2SYM(rb_intern("enums_as_integers")), + if (RTEST(rb_hash_lookup2(hash_args, ID2SYM(rb_intern("format_enums_as_integers")), Qfalse))) { options |= upb_JsonEncode_FormatEnumsAsIntegers; } diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java index 0d0fe3cc2018..03bbd9ef7b98 100644 --- a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java +++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java @@ -669,7 +669,7 @@ public static IRubyObject decode(ThreadContext context, IRubyObject recv, IRubyO * @param options [Hash] options for the decoder * preserve_proto_fieldnames: set true to use original fieldnames (default is to camelCase) * emit_defaults: set true to emit 0/false values (default is to omit them) - * enums_as_integers: set true to emit enum values as integer (default is string) + * format_enums_as_integers: set true to emit enum values as integer (default is string) */ @JRubyMethod(name = "encode_json", required = 1, optional = 1, meta = true) public static IRubyObject encodeJson( @@ -691,7 +691,7 @@ public static IRubyObject encodeJson( IRubyObject emitDefaults = options.fastARef(runtime.newSymbol("emit_defaults")); IRubyObject preserveNames = options.fastARef(runtime.newSymbol("preserve_proto_fieldnames")); - IRubyObject enumAsIntegers = options.fastARef(runtime.newSymbol("enums_as_integers")); + IRubyObject printingEnumsAsInts = options.fastARef(runtime.newSymbol("format_enums_as_integers")); if (emitDefaults != null && emitDefaults.isTrue()) { printer = printer.includingDefaultValueFields(); @@ -701,7 +701,7 @@ public static IRubyObject encodeJson( printer = printer.preservingProtoFieldNames(); } - if (enumAsIntegers != null && printingEnumsAsInts.isTrue()) { + if (printingEnumsAsInts != null && printingEnumsAsInts.isTrue()) { printer = printer.printingEnumsAsInts(); } } diff --git a/ruby/tests/encode_decode_test.rb b/ruby/tests/encode_decode_test.rb index 2b36cd1016cb..710e754990a6 100755 --- a/ruby/tests/encode_decode_test.rb +++ b/ruby/tests/encode_decode_test.rb @@ -90,7 +90,7 @@ def test_encode_json msg = A::B::C::TestMessage.new({ optional_enum: 1 }) json = A::B::C::TestMessage.encode_json( msg, - { :enums_as_integers => true } + { :format_enums_as_integers => true } ) assert_match '"optionalEnum":1', json @@ -99,7 +99,7 @@ def test_encode_json msg = A::B::C::TestMessage.new({ optional_enum: 0 }) json = A::B::C::TestMessage.encode_json( msg, - { :enums_as_integers => true, :emit_defaults => true } + { :format_enums_as_integers => true, :emit_defaults => true } ) assert_match '"optionalEnum":0', json @@ -108,7 +108,7 @@ def test_encode_json msg = A::B::C::TestMessage.new({ repeated_enum: [0,1,2,3] }) json = A::B::C::TestMessage.encode_json( msg, - { :enums_as_integers => true } + { :format_enums_as_integers => true } ) assert_match '"repeatedEnum":[0,1,2,3]', json