Class: ProtoPlugin::ServiceDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::ServiceDescriptor
- Includes:
- Commentable
- Defined in:
- lib/proto_plugin/service_descriptor.rb
Overview
A wrapper class around Google::Protobuf::ServiceDescriptorProto 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::ServiceDescriptorProto readonly
-
#parent ⇒ FileDescriptor
readonly
The file this service was defined within.
Instance Method Summary collapse
-
#file ⇒ FileDescriptor
The file descriptor this service belongs to.
-
#full_name ⇒ String
The full name of the service, including parent namespace.
-
#initialize(descriptor, parent, context) ⇒ ServiceDescriptor
constructor
A new instance of ServiceDescriptor.
-
#rpc_methods ⇒ Array<MethodDescriptor>
The methods defined for the service.
Methods included from Commentable
#comments, #leading_comments, #source_location, #trailing_comments
Constructor Details
#initialize(descriptor, parent, context) ⇒ ServiceDescriptor
Returns a new instance of ServiceDescriptor.
26 27 28 29 30 31 |
# File 'lib/proto_plugin/service_descriptor.rb', line 26 def initialize(descriptor, parent, context) super(descriptor) @descriptor = descriptor @parent = parent @context = context end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::ServiceDescriptorProto (readonly)
16 17 18 |
# File 'lib/proto_plugin/service_descriptor.rb', line 16 def descriptor @descriptor end |
#parent ⇒ FileDescriptor (readonly)
The file this service was defined within.
21 22 23 |
# File 'lib/proto_plugin/service_descriptor.rb', line 21 def parent @parent end |
Instance Method Details
#file ⇒ FileDescriptor
The file descriptor this service belongs to.
36 37 38 |
# File 'lib/proto_plugin/service_descriptor.rb', line 36 def file parent.file end |
#full_name ⇒ String
The full name of the service, including parent namespace.
46 47 48 |
# File 'lib/proto_plugin/service_descriptor.rb', line 46 def full_name @full_name ||= "#{parent.namespace}::#{name}" end |
#rpc_methods ⇒ Array<MethodDescriptor>
This method is named rpc_methods to avoid conflicting with Object#methods.
The methods defined for the service.
58 59 60 61 62 |
# File 'lib/proto_plugin/service_descriptor.rb', line 58 def rpc_methods @rpc_methods ||= @descriptor["method"].map do |m| MethodDescriptor.new(m, self, @context) end end |