aboutsummaryrefslogtreecommitdiffhomepage
path: root/ruby/ext/google/protobuf_c
diff options
context:
space:
mode:
authorGravatar Chris Fallin <cfallin@c1f.net>2015-05-02 19:02:08 -0700
committerGravatar Chris Fallin <cfallin@c1f.net>2015-05-02 19:02:08 -0700
commit16a283f7942be34eb47852832131dfef2d196f83 (patch)
treed99562c8fc9052afd1aced0aa9709a25637bdc7c /ruby/ext/google/protobuf_c
parentdcf12136835af5239f0877aa455eabbd7b88b61e (diff)
parent64678265c5ae28998d031900c2de52419a8ed7e4 (diff)
Merge pull request #334 from skippy/allow-msg-to-accept-nil
ruby: allow a message field to be unset
Diffstat (limited to 'ruby/ext/google/protobuf_c')
-rw-r--r--ruby/ext/google/protobuf_c/storage.c4
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)));