Class: ProtoPlugin::ServiceDescriptor

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

Instance Method Summary collapse

Methods included from Commentable

#comments, #leading_comments, #source_location, #trailing_comments

Constructor Details

#initialize(descriptor, parent, context) ⇒ ServiceDescriptor

Returns a new instance of ServiceDescriptor.

Parameters:

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

    The file this service was defined within.

  • context (Context)


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

#descriptorGoogle::Protobuf::ServiceDescriptorProto (readonly)

Returns:

  • (Google::Protobuf::ServiceDescriptorProto)


16
17
18
# File 'lib/proto_plugin/service_descriptor.rb', line 16

def descriptor
  @descriptor
end

#parentFileDescriptor (readonly)

The file this service was defined within.

Returns:



21
22
23
# File 'lib/proto_plugin/service_descriptor.rb', line 21

def parent
  @parent
end

Instance Method Details

#fileFileDescriptor

The file descriptor this service belongs to.

Returns:



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

def file
  parent.file
end

#full_nameString

The full name of the service, including parent namespace.

Examples:

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

Returns:

  • (String)


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

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.



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