diff options
author | Adam Greene <adam.greene@gmail.com> | 2015-05-02 13:48:23 -0700 |
---|---|---|
committer | Adam Greene <adam.greene@gmail.com> | 2015-05-02 13:48:23 -0700 |
commit | 64678265c5ae28998d031900c2de52419a8ed7e4 (patch) | |
tree | 077e1dc1ded48dde7216d11255b1b3c30ea071d4 /ruby/ext/google/protobuf_c/storage.c | |
parent | 4b2a6328bd2fe6a1d58bbe536c512c566a2673d3 (diff) | |
download | protobuf-64678265c5ae28998d031900c2de52419a8ed7e4.tar.gz protobuf-64678265c5ae28998d031900c2de52419a8ed7e4.tar.bz2 protobuf-64678265c5ae28998d031900c2de52419a8ed7e4.zip |
allow a message field to be unset
Diffstat (limited to 'ruby/ext/google/protobuf_c/storage.c')
-rw-r--r-- | ruby/ext/google/protobuf_c/storage.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ruby/ext/google/protobuf_c/storage.c b/ruby/ext/google/protobuf_c/storage.c index 5b1549d2..2ad8bd74 100644 --- a/ruby/ext/google/protobuf_c/storage.c +++ b/ruby/ext/google/protobuf_c/storage.c @@ -155,7 +155,9 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class, break; } case UPB_TYPE_MESSAGE: { - if (CLASS_OF(value) != type_class) { + if (CLASS_OF(value) == CLASS_OF(Qnil)) { + value = Qnil; + } else if (CLASS_OF(value) != type_class) { rb_raise(rb_eTypeError, "Invalid type %s to assign to submessage field.", rb_class2name(CLASS_OF(value))); |