Class: Dhall::RecordType
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Expression
#&, #*, #+, #as_dhall, #cache_key, #call, #concat, #deep_merge, #dhall_eq, #digest, #fetch, #fusion, #merge, #normalize, #resolve, #shift, #substitute, #to_cbor, #to_proc, #to_s, #|
Class Method Details
.decode(record) ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/dhall/binary.rb', line 116
def self.decode(record)
if record.empty?
EmptyRecordType.new
else
new(record: Hash[record.map { |k, v| [k, Dhall.decode(v)] }])
end
end
|
.for(types) ⇒ Object
564
565
566
567
568
569
570
|
# File 'lib/dhall/ast.rb', line 564
def self.for(types)
if types.empty?
EmptyRecordType.new
else
RecordType.new(record: types)
end
end
|
Instance Method Details
#==(other) ⇒ Object
594
595
596
|
# File 'lib/dhall/ast.rb', line 594
def ==(other)
other.respond_to?(:record) && record.to_a == other.record.to_a
end
|
#as_json ⇒ Object
602
603
604
|
# File 'lib/dhall/ast.rb', line 602
def as_json
[7, Hash[record.to_a.map { |k, v| [k, v.as_json] }.sort]]
end
|
#deep_merge_type(other) ⇒ Object
578
579
580
581
582
583
584
|
# File 'lib/dhall/ast.rb', line 578
def deep_merge_type(other)
return super unless other.class == RecordType
with(record: Hash[record.merge(other.record) { |_, v1, v2|
v1.deep_merge_type(v2)
}.sort])
end
|
#eql?(other) ⇒ Boolean
598
599
600
|
# File 'lib/dhall/ast.rb', line 598
def eql?(other)
self == other
end
|
#keys ⇒ Object
586
587
588
|
# File 'lib/dhall/ast.rb', line 586
def keys
record.keys
end
|
#merge_type(other) ⇒ Object
572
573
574
575
576
|
# File 'lib/dhall/ast.rb', line 572
def merge_type(other)
return self if other.is_a?(EmptyRecordType)
with(record: record.merge(other.record))
end
|
#slice(keys) ⇒ Object
590
591
592
|
# File 'lib/dhall/ast.rb', line 590
def slice(keys)
RecordType.for(record.select { |k, _| keys.include?(k) })
end
|