Class: Google::Protobuf::Internal::OneofBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, msg_builder) ⇒ OneofBuilder

Returns a new instance of OneofBuilder.



420
421
422
423
424
425
426
427
428
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb', line 420

def initialize(name, msg_builder)
  @msg_builder = msg_builder
  oneof_proto = Google::Protobuf::OneofDescriptorProto.new(
    :name => name
  )
  msg_proto = msg_builder.internal_msg_proto
  @oneof_index = msg_proto.oneof_decl.size
  msg_proto.oneof_decl << oneof_proto
end

Instance Method Details

#optional(name, type, number, type_class = nil, options = nil) ⇒ Object



430
431
432
433
434
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/lib/google/protobuf/descriptor_dsl.rb', line 430

def optional(name, type, number, type_class=nil, options=nil)
  @msg_builder.internal_add_field(
      :LABEL_OPTIONAL, name, type, number, type_class, options,
      oneof_index: @oneof_index)
end