Class: Gelauto::HashType
Instance Attribute Summary
Attributes inherited from GenericType
#generic_args, #ruby_type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from GenericType
#[]
Constructor Details
Returns a new instance of HashType.
12
13
14
|
# File 'lib/gelauto/hash_type.rb', line 12
def initialize
super(::Hash, [:key, :value])
end
|
Class Method Details
.introspect(obj) ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/gelauto/hash_type.rb', line 3
def self.introspect(obj)
new.tap do |var|
obj.each_pair do |key, value|
var[:key] << Gelauto.introspect(key)
var[:value] << Gelauto.introspect(value)
end
end
end
|
Instance Method Details
#merge!(other) ⇒ Object
24
25
26
27
|
# File 'lib/gelauto/hash_type.rb', line 24
def merge!(other)
self[:key].merge!(other[:key])
self[:value].merge!(other[:value])
end
|
#to_sig ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/gelauto/hash_type.rb', line 16
def to_sig
if self[:key].empty? && self[:value].empty?
'T::Hash[T.untyped, T.untyped]'
else
"T::Hash[#{self[:key].to_sig}, #{self[:value].to_sig}]"
end
end
|