diff options
author | Chris Fallin <cfallin@c1f.net> | 2015-05-02 19:02:08 -0700 |
---|---|---|
committer | Chris Fallin <cfallin@c1f.net> | 2015-05-02 19:02:08 -0700 |
commit | 16a283f7942be34eb47852832131dfef2d196f83 (patch) | |
tree | d99562c8fc9052afd1aced0aa9709a25637bdc7c /ruby/ext/google | |
parent | dcf12136835af5239f0877aa455eabbd7b88b61e (diff) | |
parent | 64678265c5ae28998d031900c2de52419a8ed7e4 (diff) | |
download | protobuf-16a283f7942be34eb47852832131dfef2d196f83.tar.gz protobuf-16a283f7942be34eb47852832131dfef2d196f83.tar.bz2 protobuf-16a283f7942be34eb47852832131dfef2d196f83.zip |
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')
-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))); |