Class: ProtoPlugin::MethodDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::MethodDescriptor
- Includes:
- Commentable
- Defined in:
- lib/proto_plugin/method_descriptor.rb
Overview
A wrapper class around Google::Protobuf::MethodDescriptorProto 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::MethodDescriptorProto readonly
-
#service ⇒ ServiceDescriptor
readonly
The service this method was defined in.
Instance Method Summary collapse
-
#bidirectional_streaming? ⇒ Boolean
Returns true if both the client and server may send multiple streamed messages.
-
#client_streaming? ⇒ Boolean
Returns true if the client may stream multiple client messages.
-
#file ⇒ FileDescriptor
The file descriptor this method belongs to.
-
#initialize(descriptor, service, context) ⇒ MethodDescriptor
constructor
A new instance of MethodDescriptor.
-
#input ⇒ MessageDescriptor
Returns the
MessageDescriptorof the method’s input type. -
#output ⇒ MessageDescriptor
Returns the
MessageDescriptorof the method’s output type. -
#server_streaming? ⇒ Boolean
Returns true if the server may stream multiple server messages.
-
#unary? ⇒ Boolean
Returns true if both the client and server only may send single messages.
Methods included from Commentable
#comments, #leading_comments, #source_location, #trailing_comments
Constructor Details
#initialize(descriptor, service, context) ⇒ MethodDescriptor
Returns a new instance of MethodDescriptor.
26 27 28 29 30 31 |
# File 'lib/proto_plugin/method_descriptor.rb', line 26 def initialize(descriptor, service, context) super(descriptor) @descriptor = descriptor @service = service @context = context end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::MethodDescriptorProto (readonly)
16 17 18 |
# File 'lib/proto_plugin/method_descriptor.rb', line 16 def descriptor @descriptor end |
#service ⇒ ServiceDescriptor (readonly)
The service this method was defined in.
21 22 23 |
# File 'lib/proto_plugin/method_descriptor.rb', line 21 def service @service end |
Instance Method Details
#bidirectional_streaming? ⇒ Boolean
Returns true if both the client and server may send multiple streamed messages.
78 79 80 |
# File 'lib/proto_plugin/method_descriptor.rb', line 78 def bidirectional_streaming? client_streaming? && server_streaming? end |
#client_streaming? ⇒ Boolean
Returns true if the client may stream multiple client messages.
57 58 59 |
# File 'lib/proto_plugin/method_descriptor.rb', line 57 def client_streaming? descriptor.client_streaming end |
#file ⇒ FileDescriptor
The file descriptor this method belongs to.
36 37 38 |
# File 'lib/proto_plugin/method_descriptor.rb', line 36 def file service.file end |
#input ⇒ MessageDescriptor
Returns the MessageDescriptor of the method’s input type.
43 44 45 |
# File 'lib/proto_plugin/method_descriptor.rb', line 43 def input @context.type_by_proto_name(input_type) end |
#output ⇒ MessageDescriptor
Returns the MessageDescriptor of the method’s output type.
50 51 52 |
# File 'lib/proto_plugin/method_descriptor.rb', line 50 def output @context.type_by_proto_name(output_type) end |
#server_streaming? ⇒ Boolean
Returns true if the server may stream multiple server messages.
64 65 66 |
# File 'lib/proto_plugin/method_descriptor.rb', line 64 def server_streaming? descriptor.server_streaming end |
#unary? ⇒ Boolean
Returns true if both the client and server only may send single messages.
71 72 73 |
# File 'lib/proto_plugin/method_descriptor.rb', line 71 def unary? !client_streaming? && !server_streaming? end |