Class: Gapic::Schema::Message

Inherits:
Proto
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gapic/schema/wrappers.rb

Overview

Wrapper for a protobuf Message.

Instance Attribute Summary collapse

Attributes inherited from Proto

#address, #descriptor, #docs, #parent

Instance Method Summary collapse

Methods inherited from Proto

#containing_api, #containing_file, #docs_leading_comments, #leading_comments, #leading_detached_comments, #path, #span, #trailing_comments

Constructor Details

#initialize(descriptor, address, docs, fields, extensions, nested_messages, nested_enums) ⇒ Message

Initializes a message object.

Parameters:

  • descriptor (Google::Protobuf::DescriptorProto) —

    the protobuf representation of this service.

  • address (Enumerable<String>) —

    The address of the proto. See #address for more info.

  • docs (Google::Protobuf::SourceCodeInfo::Location) —

    The docs of the proto. See #docs for more info.

  • fields (Enumerable<Field>) —

    The fields of this message.

  • extensions (Enumerable<Field>) —

    The extensions of this message.

  • nested_messages (Enumerable<Message>) —

    The nested message declarations of this message.

  • nested_enums (Enumerable<Enum>) —

    The nested enum declarations of this message.



536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/gapic/schema/wrappers.rb', line 536

def initialize descriptor, address, docs, fields, extensions,
               nested_messages, nested_enums
  super descriptor, address, docs
  @fields = fields || []
  @extensions = extensions || []
  @nested_messages = nested_messages || []
  @nested_enums = nested_enums || []

  @fields.each          { |f| f.parent = self }
  @extensions.each      { |x| x.parent = self }
  @nested_messages.each { |m| m.parent = self }
  @nested_enums.each    { |e| e.parent = self }
end

Instance Attribute Details

#extensions ⇒ Object (readonly)

@ return [Enumerable] The extensions of a message.



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/gapic/schema/wrappers.rb', line 519

class Message < Proto
  extend Forwardable
  attr_reader :fields, :extensions, :nested_messages, :nested_enums

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param fields [Enumerable<Field>] The fields of this message.
  # @param extensions [Enumerable<Field>] The extensions of this message.
  # @param nested_messages [Enumerable<Message>] The nested message
  #   declarations of this message.
  # @param nested_enums [Enumerable<Enum>] The nested enum declarations
  #   of this message.
  def initialize descriptor, address, docs, fields, extensions,
                 nested_messages, nested_enums
    super descriptor, address, docs
    @fields = fields || []
    @extensions = extensions || []
    @nested_messages = nested_messages || []
    @nested_enums = nested_enums || []

    @fields.each          { |f| f.parent = self }
    @extensions.each      { |x| x.parent = self }
    @nested_messages.each { |m| m.parent = self }
    @nested_enums.each    { |e| e.parent = self }
  end

  # @return [Google::Api::ResourceDescriptor] A representation of the resource.
  #   This is generally intended to be attached to the "name" field.
  #   See `google/api/resource.proto`.
  def resource
    options[:".google.api.resource"] if options
  end

  # @return [Boolean] whether this type is a map entry
  def map_entry?
    descriptor.options&.map_entry
  end

  # @!method name
  #   @return [String] the unqualified name of the message.
  # @!method oneof_decl
  #   @return [Array<Google::Protobuf::OneofDescriptorProto>]
  #     The oneofs declared in this message.
  # @!method options
  #   @return [Array<Google::Protobuf::MessageOptions>]
  #     The options of this meessage.
  def_delegators(
    :descriptor,
    :name,
    :oneof_decl,
    :options
  )
end

#fields ⇒ Object (readonly)

@ return [Enumerable] The fields of a message.



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/gapic/schema/wrappers.rb', line 519

class Message < Proto
  extend Forwardable
  attr_reader :fields, :extensions, :nested_messages, :nested_enums

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param fields [Enumerable<Field>] The fields of this message.
  # @param extensions [Enumerable<Field>] The extensions of this message.
  # @param nested_messages [Enumerable<Message>] The nested message
  #   declarations of this message.
  # @param nested_enums [Enumerable<Enum>] The nested enum declarations
  #   of this message.
  def initialize descriptor, address, docs, fields, extensions,
                 nested_messages, nested_enums
    super descriptor, address, docs
    @fields = fields || []
    @extensions = extensions || []
    @nested_messages = nested_messages || []
    @nested_enums = nested_enums || []

    @fields.each          { |f| f.parent = self }
    @extensions.each      { |x| x.parent = self }
    @nested_messages.each { |m| m.parent = self }
    @nested_enums.each    { |e| e.parent = self }
  end

  # @return [Google::Api::ResourceDescriptor] A representation of the resource.
  #   This is generally intended to be attached to the "name" field.
  #   See `google/api/resource.proto`.
  def resource
    options[:".google.api.resource"] if options
  end

  # @return [Boolean] whether this type is a map entry
  def map_entry?
    descriptor.options&.map_entry
  end

  # @!method name
  #   @return [String] the unqualified name of the message.
  # @!method oneof_decl
  #   @return [Array<Google::Protobuf::OneofDescriptorProto>]
  #     The oneofs declared in this message.
  # @!method options
  #   @return [Array<Google::Protobuf::MessageOptions>]
  #     The options of this meessage.
  def_delegators(
    :descriptor,
    :name,
    :oneof_decl,
    :options
  )
end

#nested_enums ⇒ Object (readonly)

@ return [Enumerable] The nested enum declarations of a message.



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/gapic/schema/wrappers.rb', line 519

class Message < Proto
  extend Forwardable
  attr_reader :fields, :extensions, :nested_messages, :nested_enums

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param fields [Enumerable<Field>] The fields of this message.
  # @param extensions [Enumerable<Field>] The extensions of this message.
  # @param nested_messages [Enumerable<Message>] The nested message
  #   declarations of this message.
  # @param nested_enums [Enumerable<Enum>] The nested enum declarations
  #   of this message.
  def initialize descriptor, address, docs, fields, extensions,
                 nested_messages, nested_enums
    super descriptor, address, docs
    @fields = fields || []
    @extensions = extensions || []
    @nested_messages = nested_messages || []
    @nested_enums = nested_enums || []

    @fields.each          { |f| f.parent = self }
    @extensions.each      { |x| x.parent = self }
    @nested_messages.each { |m| m.parent = self }
    @nested_enums.each    { |e| e.parent = self }
  end

  # @return [Google::Api::ResourceDescriptor] A representation of the resource.
  #   This is generally intended to be attached to the "name" field.
  #   See `google/api/resource.proto`.
  def resource
    options[:".google.api.resource"] if options
  end

  # @return [Boolean] whether this type is a map entry
  def map_entry?
    descriptor.options&.map_entry
  end

  # @!method name
  #   @return [String] the unqualified name of the message.
  # @!method oneof_decl
  #   @return [Array<Google::Protobuf::OneofDescriptorProto>]
  #     The oneofs declared in this message.
  # @!method options
  #   @return [Array<Google::Protobuf::MessageOptions>]
  #     The options of this meessage.
  def_delegators(
    :descriptor,
    :name,
    :oneof_decl,
    :options
  )
end

#nested_messages ⇒ Object (readonly)

@ return [Enumerable] The nested message declarations of a message.



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/gapic/schema/wrappers.rb', line 519

class Message < Proto
  extend Forwardable
  attr_reader :fields, :extensions, :nested_messages, :nested_enums

  # Initializes a message object.
  # @param descriptor [Google::Protobuf::DescriptorProto] the protobuf
  #   representation of this service.
  # @param address [Enumerable<String>] The address of the proto. See
  #   #address for more info.
  # @param docs [Google::Protobuf::SourceCodeInfo::Location] The docs
  #   of the proto. See #docs for more info.
  # @param fields [Enumerable<Field>] The fields of this message.
  # @param extensions [Enumerable<Field>] The extensions of this message.
  # @param nested_messages [Enumerable<Message>] The nested message
  #   declarations of this message.
  # @param nested_enums [Enumerable<Enum>] The nested enum declarations
  #   of this message.
  def initialize descriptor, address, docs, fields, extensions,
                 nested_messages, nested_enums
    super descriptor, address, docs
    @fields = fields || []
    @extensions = extensions || []
    @nested_messages = nested_messages || []
    @nested_enums = nested_enums || []

    @fields.each          { |f| f.parent = self }
    @extensions.each      { |x| x.parent = self }
    @nested_messages.each { |m| m.parent = self }
    @nested_enums.each    { |e| e.parent = self }
  end

  # @return [Google::Api::ResourceDescriptor] A representation of the resource.
  #   This is generally intended to be attached to the "name" field.
  #   See `google/api/resource.proto`.
  def resource
    options[:".google.api.resource"] if options
  end

  # @return [Boolean] whether this type is a map entry
  def map_entry?
    descriptor.options&.map_entry
  end

  # @!method name
  #   @return [String] the unqualified name of the message.
  # @!method oneof_decl
  #   @return [Array<Google::Protobuf::OneofDescriptorProto>]
  #     The oneofs declared in this message.
  # @!method options
  #   @return [Array<Google::Protobuf::MessageOptions>]
  #     The options of this meessage.
  def_delegators(
    :descriptor,
    :name,
    :oneof_decl,
    :options
  )
end

Instance Method Details

#map_entry? ⇒ Boolean

Returns whether this type is a map entry.

Returns:

  • (Boolean) —

    whether this type is a map entry



558
559
560
# File 'lib/gapic/schema/wrappers.rb', line 558

def map_entry?
  descriptor.options&.map_entry
end

#name ⇒ String

Returns the unqualified name of the message.

Returns:

  • (String) —

    the unqualified name of the message.



570
571
572
573
574
575
# File 'lib/gapic/schema/wrappers.rb', line 570

def_delegators(
  :descriptor,
  :name,
  :oneof_decl,
  :options
)

#oneof_decl ⇒ Array<Google::Protobuf::OneofDescriptorProto>

Returns The oneofs declared in this message.

Returns:



570
571
572
573
574
575
# File 'lib/gapic/schema/wrappers.rb', line 570

def_delegators(
  :descriptor,
  :name,
  :oneof_decl,
  :options
)

#options ⇒ Array<Google::Protobuf::MessageOptions>

Returns The options of this meessage.

Returns:



570
571
572
573
574
575
# File 'lib/gapic/schema/wrappers.rb', line 570

def_delegators(
  :descriptor,
  :name,
  :oneof_decl,
  :options
)

#resource ⇒ Google::Api::ResourceDescriptor

Returns A representation of the resource. This is generally intended to be attached to the "name" field. See google/api/resource.proto.

Returns:

  • (Google::Api::ResourceDescriptor) —

    A representation of the resource. This is generally intended to be attached to the "name" field. See google/api/resource.proto.



553
554
555
# File 'lib/gapic/schema/wrappers.rb', line 553

def resource
  options[:".google.api.resource"] if options
end