Class: Skit::JsonSchema::Definitions::HashPropertyType
- Inherits:
-
Object
- Object
- Skit::JsonSchema::Definitions::HashPropertyType
- Extended by:
- T::Sig
- Defined in:
- lib/skit/json_schema/definitions/hash_property_type.rb
Instance Attribute Summary collapse
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Instance Method Summary collapse
-
#initialize(value_type:, nullable: false) ⇒ HashPropertyType
constructor
A new instance of HashPropertyType.
- #to_sorbet_type ⇒ Object
- #with_nullable ⇒ Object
Constructor Details
#initialize(value_type:, nullable: false) ⇒ HashPropertyType
Returns a new instance of HashPropertyType.
17 18 19 20 |
# File 'lib/skit/json_schema/definitions/hash_property_type.rb', line 17 def initialize(value_type:, nullable: false) @value_type = value_type @nullable = nullable end |
Instance Attribute Details
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
14 15 16 |
# File 'lib/skit/json_schema/definitions/hash_property_type.rb', line 14 def nullable @nullable end |
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
11 12 13 |
# File 'lib/skit/json_schema/definitions/hash_property_type.rb', line 11 def value_type @value_type end |
Instance Method Details
#to_sorbet_type ⇒ Object
23 24 25 26 27 |
# File 'lib/skit/json_schema/definitions/hash_property_type.rb', line 23 def to_sorbet_type value_type_str = @value_type.to_sorbet_type hash_type = "T::Hash[String, #{value_type_str}]" nullable ? "T.nilable(#{hash_type})" : hash_type end |
#with_nullable ⇒ Object
30 31 32 |
# File 'lib/skit/json_schema/definitions/hash_property_type.rb', line 30 def with_nullable HashPropertyType.new(value_type: @value_type, nullable: true) end |