Class: Apigen::OneofType
- Inherits:
-
Object
- Object
- Apigen::OneofType
- Defined in:
- lib/apigen/models/oneof_type.rb
Overview
OneofType represents a union type, aka “either or”.
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
-
#discriminator ⇒ Object
The discriminator tells us which property defines the type of the object.
-
#initialize ⇒ OneofType
constructor
A new instance of OneofType.
- #map(mapping) ⇒ Object
- #validate(model_registry) ⇒ Object
Constructor Details
#initialize ⇒ OneofType
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
#mapping ⇒ Object (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
#discriminator ⇒ Object
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 |