Class: ProtoPlugin::MethodDescriptor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProtoPlugin::MethodDescriptor
- 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.
-
#initialize(descriptor, service, context) ⇒ MethodDescriptor
constructor
A new instance of MethodDescriptor.
-
#input ⇒ MessageDescriptor
Returns the
MessageDescriptor
of the method’s input type. -
#output ⇒ MessageDescriptor
Returns the
MessageDescriptor
of 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.
Constructor Details
#initialize(descriptor, service, context) ⇒ MethodDescriptor
Returns a new instance of MethodDescriptor.
24 25 26 27 28 29 |
# File 'lib/proto_plugin/method_descriptor.rb', line 24 def initialize(descriptor, service, context) super(descriptor) @descriptor = descriptor @service = service @context = context end |
Instance Attribute Details
#descriptor ⇒ Google::Protobuf::MethodDescriptorProto (readonly)
14 15 16 |
# File 'lib/proto_plugin/method_descriptor.rb', line 14 def descriptor @descriptor end |
#service ⇒ ServiceDescriptor (readonly)
The service this method was defined in.
19 20 21 |
# File 'lib/proto_plugin/method_descriptor.rb', line 19 def service @service end |
Instance Method Details
#bidirectional_streaming? ⇒ Boolean
Returns true if both the client and server may send multiple streamed messages.
69 70 71 |
# File 'lib/proto_plugin/method_descriptor.rb', line 69 def bidirectional_streaming? client_streaming? && server_streaming? end |
#client_streaming? ⇒ Boolean
Returns true if the client may stream multiple client messages.
48 49 50 |
# File 'lib/proto_plugin/method_descriptor.rb', line 48 def client_streaming? descriptor.client_streaming end |
#input ⇒ MessageDescriptor
Returns the MessageDescriptor
of the method’s input type.
34 35 36 |
# File 'lib/proto_plugin/method_descriptor.rb', line 34 def input @context.type_by_proto_name(input_type) end |
#output ⇒ MessageDescriptor
Returns the MessageDescriptor
of the method’s output type.
41 42 43 |
# File 'lib/proto_plugin/method_descriptor.rb', line 41 def output @context.type_by_proto_name(output_type) end |
#server_streaming? ⇒ Boolean
Returns true if the server may stream multiple server messages.
55 56 57 |
# File 'lib/proto_plugin/method_descriptor.rb', line 55 def server_streaming? descriptor.server_streaming end |
#unary? ⇒ Boolean
Returns true if both the client and server only may send single messages.
62 63 64 |
# File 'lib/proto_plugin/method_descriptor.rb', line 62 def unary? !client_streaming? && !server_streaming? end |