Class: Apigen::OneofType

Inherits:
Object
  • Object
show all
Defined in:
lib/apigen/models/oneof_type.rb

Overview

OneofType represents a union type, aka “either or”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOneofType

Returns a new instance of OneofType.



16
17
18
19
# File 'lib/apigen/models/oneof_type.rb', line 16

def initialize
  @discriminator = nil
  @mapping = {}
end

Instance Attribute Details

#mappingObject (readonly)

Returns the value of attribute mapping.



14
15
16
# File 'lib/apigen/models/oneof_type.rb', line 14

def mapping
  @mapping
end

Instance Method Details

#discriminatorObject

The discriminator tells us which property defines the type of the object.

Setting a discriminator is optional, but recommended.



13
# File 'lib/apigen/models/oneof_type.rb', line 13

attribute_setter_getter :discriminator

#map(mapping) ⇒ Object



21
22
23
# File 'lib/apigen/models/oneof_type.rb', line 21

def map(mapping)
  @mapping = mapping
end

#validate(model_registry) ⇒ Object



25
26
27
28
29
# File 'lib/apigen/models/oneof_type.rb', line 25

def validate(model_registry)
  @mapping.each do |key, value|
    validate_mapping_item(model_registry, key, value)
  end
end