diff options
author | Zachary Anker <zanker@squareup.com> | 2017-09-14 08:35:13 -0700 |
---|---|---|
committer | Zachary Anker <zanker@squareup.com> | 2017-09-20 11:38:05 -0700 |
commit | 83264bd160326fe808c2d5bfbebe54e77f781152 (patch) | |
tree | 68c4391f0cbf1a6fcdda11e4028a66af108f87e5 /ruby/ext/google/protobuf_c | |
parent | d1bc27caef8377a710370189675cb0958443e8f1 (diff) | |
download | protobuf-83264bd160326fe808c2d5bfbebe54e77f781152.tar.gz protobuf-83264bd160326fe808c2d5bfbebe54e77f781152.tar.bz2 protobuf-83264bd160326fe808c2d5bfbebe54e77f781152.zip |
Fixed to_h with repeated messages to return hashes in Ruby
Diffstat (limited to 'ruby/ext/google/protobuf_c')
-rw-r--r-- | ruby/ext/google/protobuf_c/message.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 29911140..82c730b5 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -419,6 +419,13 @@ VALUE Message_to_h(VALUE _self) { msg_value = Map_to_h(msg_value); } else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) { msg_value = RepeatedField_to_ary(msg_value); + + if (upb_fieldddef_type(field) == UPB_TYPE_MESSAGE) { + for (int i = 0; i < RARRAY_LEN(msg_value); i++) { + VALUE elem = rb_ary_entry(msg_value, i); + rb_ary_store(msg_value, i, Message_to_h(elem)); + } + } } else if (msg_value != Qnil && upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { msg_value = Message_to_h(msg_value); |