Sha256: 6bd01afeda312dc016dcf9ea4e0dad1d98396dca6e58d0325baa821d2c9e16f3

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

class ProtobufDescriptor
  # Describes a service.
  #
  # See ServiceDescriptorProto[https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto#188]
  class ServiceDescriptor
    include ProtobufDescriptor::HasParent
    include ProtobufDescriptor::NamedChild
    include ProtobufDescriptor::HasChildren

    # The parent {ProtobufDescriptor::FileDescriptor}
    attr_reader :parent

    # The +ServiceDescriptorProto+ this +ServiceDescriptor+ is wrapping
    attr_reader :service_descriptor_proto

    # Set of methods contained within this service, as a NamedCollection of
    # {ProtobufDescriptor::ServiceDescriptor::MethodDescriptor MethodDescriptors}
    attr_reader :method
    alias_method :methods, :method

    # Field index is hard-coded since these are a bit annoying to grab
    # consistently with the different protocol buffer implementations.
    self.register_children(:method, 2)

    def initialize(parent, service_descriptor_proto)
      @parent = parent
      @service_descriptor_proto = service_descriptor_proto
      @method = ProtobufDescriptor::NamedCollection.new(
          service_descriptor_proto.method.map { |m|
              ProtobufDescriptor::MethodDescriptor.new(self, m)
          })
    end

    # The name of the service
    def name; service_descriptor_proto.name; end

    # The +ServiceOptions+ for this service.
    def options; service_descriptor_proto.options; end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
protobuf_descriptor-1.1.2 lib/protobuf_descriptor/service_descriptor.rb
protobuf_descriptor-1.1.1 lib/protobuf_descriptor/service_descriptor.rb
protobuf_descriptor-1.1.0 lib/protobuf_descriptor/service_descriptor.rb