Sha256: 33557a01b5b821245b16cef5187faf7be4a0b64aca00a39e528c3577ec8b967e

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

class ProtobufDescriptor
  # Describes a method of a service.
  #
  # See MethodDescriptorProto[https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto#196]
  class MethodDescriptor
    include ProtobufDescriptor::HasParent

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

    # The +MethodDescriptorProto+ this +MethodDescriptor+ is wrapping
    attr_reader :method_descriptor_proto

    def initialize(parent, method_descriptor_proto)
      @parent = parent
      @method_descriptor_proto = method_descriptor_proto
    end

    # The name of the service method
    def name
      method_descriptor_proto.name
    end

    # The +MethodOptions+ for the service method
    def options
      method_descriptor_proto.options
    end

    # Input type name for the service method. This is resolved in the same way
    # as FieldDescriptorProto.type_name, but must refer to a message type.
    def input_type_name
      method_descriptor_proto.input_type
    end

    # Output type name for the service method. This is resolved in the same way
    # as FieldDescriptorProto.type_name, but must refer to a message type.
    def output_type_name
      method_descriptor_proto.output_type
    end

    # Resolves the method's +input_type_name+, returning the
    # {ProtobufDescriptor::MessageDescriptor} that this method receives.
    def resolve_input_type
      protobuf_descriptor.resolve_type_name(input_type_name, file_descriptor)
    end

    # Resolves the method's +output_type_name+, returning the
    # {ProtobufDescriptor::MessageDescriptor} that this method
    # returns.
    def resolve_output_type
      protobuf_descriptor.resolve_type_name(output_type_name, file_descriptor)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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