Class: Skit::JsonSchema::Definitions::HashPropertyType

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/skit/json_schema/definitions/hash_property_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nullableObject (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_typeObject (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_typeObject



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_nullableObject



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