Class: Skit::JsonSchema::Definitions::UnionPropertyType
- Inherits:
-
Object
- Object
- Skit::JsonSchema::Definitions::UnionPropertyType
- Extended by:
- T::Sig
- Defined in:
- lib/skit/json_schema/definitions/union_property_type.rb
Instance Attribute Summary collapse
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(types:, nullable: false) ⇒ UnionPropertyType
constructor
A new instance of UnionPropertyType.
- #to_sorbet_type ⇒ Object
- #with_nullable ⇒ Object
Constructor Details
#initialize(types:, nullable: false) ⇒ UnionPropertyType
Returns a new instance of UnionPropertyType.
22 23 24 25 |
# File 'lib/skit/json_schema/definitions/union_property_type.rb', line 22 def initialize(types:, nullable: false) @types = types @nullable = nullable end |
Instance Attribute Details
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
14 15 16 |
# File 'lib/skit/json_schema/definitions/union_property_type.rb', line 14 def nullable @nullable end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
11 12 13 |
# File 'lib/skit/json_schema/definitions/union_property_type.rb', line 11 def types @types end |
Instance Method Details
#to_sorbet_type ⇒ Object
28 29 30 31 |
# File 'lib/skit/json_schema/definitions/union_property_type.rb', line 28 def to_sorbet_type union_str = "T.any(#{@types.map(&:to_sorbet_type).join(", ")})" @nullable ? "T.nilable(#{union_str})" : union_str end |
#with_nullable ⇒ Object
34 35 36 |
# File 'lib/skit/json_schema/definitions/union_property_type.rb', line 34 def with_nullable UnionPropertyType.new(types: @types, nullable: true) end |