From 64678265c5ae28998d031900c2de52419a8ed7e4 Mon Sep 17 00:00:00 2001 From: Adam Greene Date: Sat, 2 May 2015 13:48:23 -0700 Subject: allow a message field to be unset --- ruby/ext/google/protobuf_c/storage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ruby/ext/google') 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))); -- cgit v1.2.3