Class: ProtoPlugin::MessageDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::MessageDescriptor
- Defined in:
- lib/proto_plugin/message_descriptor.rb
Overview
A wrapper class around Google::Protobuf::DescriptorProto
which provides helpers and more idiomatic Ruby access patterns.
Any method not defined directly is delegated to the descriptor the wrapper was initialized with.
Instance Attribute Summary collapse
- #descriptor ⇒ Google::Protobuf::DescriptorProto readonly
-
#parent ⇒ FileDescriptor, MessageDescriptor
readonly
The file or message descriptor this message was defined within.
Instance Method Summary collapse
-
#enums ⇒ Array<EnumDescriptor>
The enums defined as children of this message.
-
#full_name ⇒ String
The full name of the message, including parent namespace.
-
#initialize(descriptor, parent) ⇒ MessageDescriptor
constructor
A new instance of MessageDescriptor.
-
#messages ⇒ Array<MessageDescriptor>
The messages defined as children of this message.
Constructor Details
#initialize(descriptor, parent) ⇒ MessageDescriptor
Returns a new instance of MessageDescriptor.
26 27 28 29 30 |
# File 'lib/proto_plugin/message_descriptor.rb', line 26 def initialize(descriptor, parent) super(descriptor) @descriptor = descriptor @parent = parent end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::DescriptorProto (readonly)
15 16 17 |
# File 'lib/proto_plugin/message_descriptor.rb', line 15 def descriptor @descriptor end |
#parent ⇒ FileDescriptor, MessageDescriptor (readonly)
The file or message descriptor this message was defined within.
21 22 23 |
# File 'lib/proto_plugin/message_descriptor.rb', line 21 def parent @parent end |
Instance Method Details
#enums ⇒ Array<EnumDescriptor>
The enums defined as children of this message.
38 39 40 41 42 |
# File 'lib/proto_plugin/message_descriptor.rb', line 38 def enums @enums ||= @descriptor.enum_type.map do |e| EnumDescriptor.new(e, self) end end |
#full_name ⇒ String
The full name of the message, including parent namespace.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/proto_plugin/message_descriptor.rb', line 62 def full_name @full_name ||= begin prefix = case parent when MessageDescriptor parent.full_name when FileDescriptor parent.namespace end "#{prefix}::#{name}" end end |
#messages ⇒ Array<MessageDescriptor>
The messages defined as children of this message.
50 51 52 53 54 |
# File 'lib/proto_plugin/message_descriptor.rb', line 50 def @nested_messages ||= @descriptor.nested_type.map do |m| MessageDescriptor.new(m, self) end end |