You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that #1198 has been closed as fixed. However, I am unable to figure out how to actually access any custom options on a message's descriptor. Calling to_h on the MessageOptions object returns {}, but to_json returns a promising value.
Below are some things I have tried, but have not found an access pattern that works.
sandbox_pb.rb (generated using protoc -I . --ruby_out=. sandbox.proto)
# frozen_string_literal: true# Generated by the protocol buffer compiler. DO NOT EDIT!# source: sandbox.protorequire'google/protobuf'require'google/protobuf/descriptor_pb'descriptor_data="\n\rsandbox.proto\x1a google/protobuf/descriptor.proto\"\x16\n\tMyMessage:\t\x8a\xb5\x18\x05hello:;\n\x10my_custom_option\x12\x1f.google.protobuf.MessageOptions\x18\xd1\x86\x03\x01(\tb\x06proto3"pool=Google::Protobuf::DescriptorPool.generated_poolpool.add_serialized_file(descriptor_data)MyMessage= ::Google::Protobuf::DescriptorPool.generated_pool.lookup("MyMessage").msgclass
require_relative"sandbox_pb"# => trueMyMessage.descriptor.options# => <Google::Protobuf::MessageOptions: uninterpreted_option: []>MyMessage.descriptor.options.to_h# => {}MyMessage.descriptor.options.to_json# => "{\"[my_custom_option]\":\"hello\"}"MyMessage.descriptor.options["my_custom_option"]# => nilMyMessage.descriptor.options["[my_custom_option]"]# => nilMyMessage.descriptor.options["(my_custom_option)"]# => nilMyMessage.descriptor.options.my_custom_option# `method_missing': undefined method `my_custom_option' for an instance of Google::Protobuf::MessageOptions (NoMethodError)
It appears that #1198 has been closed as fixed. However, I am unable to figure out how to actually access any custom options on a message's descriptor. Calling
to_h
on theMessageOptions
object returns{}
, butto_json
returns a promising value.Below are some things I have tried, but have not found an access pattern that works.
Example
sandbox.proto
sandbox_pb.rb
(generated usingprotoc -I . --ruby_out=. sandbox.proto
)Versions:
The text was updated successfully, but these errors were encountered: