Class: ProtoPlugin::ServiceDescriptor

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

Instance Method Summary collapse

Constructor Details

#initialize(descriptor, parent) ⇒ ServiceDescriptor

Returns a new instance of ServiceDescriptor.

Parameters:

  • descriptor (Google::Protobuf::ServiceDescriptorProto)
  • parent (FileDescriptor)

    The file this service was defined within.



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

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

Instance Attribute Details

#descriptorGoogle::Protobuf::ServiceDescriptorProto (readonly)

Returns:

  • (Google::Protobuf::ServiceDescriptorProto)


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

def descriptor
  @descriptor
end

#parentFileDescriptor (readonly)

The file this service was defined within.

Returns:



19
20
21
# File 'lib/proto_plugin/service_descriptor.rb', line 19

def parent
  @parent
end

Instance Method Details

#full_nameString

The full name of the service, including parent namespace.

Examples:

"My::Ruby::Package::ServiceName"

Returns:

  • (String)


35
36
37
# File 'lib/proto_plugin/service_descriptor.rb', line 35

def full_name
  @full_name ||= "#{parent.namespace}::#{name}"
end

#rpc_methodsArray<MethodDescriptor>

Note:

This method is named rpc_methods to avoid conflicting with Object#methods.

The methods defined for the service.



47
48
49
50
51
# File 'lib/proto_plugin/service_descriptor.rb', line 47

def rpc_methods
  @rpc_methods ||= @descriptor["method"].map do |m|
    MethodDescriptor.new(m, self)
  end
end