Class: Apiwork::Introspection::Param::Union
- Defined in:
- lib/apiwork/introspection/param/union.rb
Overview
Union param representing a value that can be one of several types.
Instance Method Summary collapse
-
#discriminator ⇒ Symbol?
The discriminator for this param.
-
#to_h ⇒ Hash
Converts this param to a hash.
-
#union? ⇒ Boolean
Whether this param is a union.
-
#variants ⇒ Array<Param::Base>
The variants for this param.
Methods inherited from Base
#array?, #binary?, #boolean?, #boundable?, #concrete?, #date?, #datetime?, #decimal?, #default?, #deprecated?, #description, #enum?, #enum_reference?, #formattable?, #initialize, #integer?, #literal?, #nullable?, #number?, #numeric?, #object?, #optional?, #partial?, #record?, #reference?, #scalar?, #string?, #tag, #time?, #type, #unknown?, #uuid?
Constructor Details
This class inherits a constructor from Apiwork::Introspection::Param::Base
Instance Method Details
#discriminator ⇒ Symbol?
The discriminator for this param.
32 33 34 |
# File 'lib/apiwork/introspection/param/union.rb', line 32 def discriminator @dump[:discriminator] end |
#to_h ⇒ Hash
Converts this param to a hash.
48 49 50 51 52 53 |
# File 'lib/apiwork/introspection/param/union.rb', line 48 def to_h result = super result[:discriminator] = discriminator result[:variants] = variants.map(&:to_h) result end |
#union? ⇒ Boolean
Whether this param is a union.
40 41 42 |
# File 'lib/apiwork/introspection/param/union.rb', line 40 def union? true end |
#variants ⇒ Array<Param::Base>
The variants for this param.
24 25 26 |
# File 'lib/apiwork/introspection/param/union.rb', line 24 def variants @variants ||= @dump[:variants].map { |dump| Param.build(dump) } end |