Class: ProtoPlugin::MethodDescriptor

Inherits:
SimpleDelegator
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(descriptor, service) ⇒ MethodDescriptor

Returns a new instance of MethodDescriptor.

Parameters:

  • descriptor (Google::Protobuf::MethodDescriptorProto)
  • service (ServiceDescriptor)

    The service this method was defined in.



23
24
25
26
27
# File 'lib/proto_plugin/method_descriptor.rb', line 23

def initialize(descriptor, service)
  super(descriptor)
  @descriptor = descriptor
  @service = service
end

Instance Attribute Details

#descriptorGoogle::Protobuf::MethodDescriptorProto (readonly)

Returns:

  • (Google::Protobuf::MethodDescriptorProto)


14
15
16
# File 'lib/proto_plugin/method_descriptor.rb', line 14

def descriptor
  @descriptor
end

#serviceServiceDescriptor (readonly)

The service this method was defined in.

Returns:



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.

Returns:

  • (Boolean)


53
54
55
# File 'lib/proto_plugin/method_descriptor.rb', line 53

def bidirectional_streaming?
  client_streaming? && server_streaming?
end

#client_streaming?Boolean

Returns true if the client may stream multiple client messages.

Returns:

  • (Boolean)


32
33
34
# File 'lib/proto_plugin/method_descriptor.rb', line 32

def client_streaming?
  descriptor.client_streaming
end

#server_streaming?Boolean

Returns true if the server may stream multiple server messages.

Returns:

  • (Boolean)


39
40
41
# File 'lib/proto_plugin/method_descriptor.rb', line 39

def server_streaming?
  descriptor.server_streaming
end

#unary?Boolean

Returns true if both the client and server only may send single messages.

Returns:

  • (Boolean)


46
47
48
# File 'lib/proto_plugin/method_descriptor.rb', line 46

def unary?
  !client_streaming? && !server_streaming?
end