Class: Dhall::ToMap
- Inherits:
-
Expression
show all
- Defined in:
- lib/dhall/ast.rb,
lib/dhall/binary.rb,
lib/dhall/normalize.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Expression
#&, #*, #+, #annotate, #as_dhall, #cache_key, #call, #concat, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #fusion, #merge, #resolve, #shift, #slice, #substitute, #to_binary, #to_cbor, #to_proc, #to_s, #|
Class Method Details
.decode(record, type = nil) ⇒ Object
117
118
119
120
121
122
|
# File 'lib/dhall/binary.rb', line 117
def self.decode(record, type=nil)
new(
record: Dhall.decode(record),
type: type.nil? ? nil : Dhall.decode(type)
)
end
|
Instance Method Details
#as_json ⇒ Object
663
664
665
666
|
# File 'lib/dhall/ast.rb', line 663
def as_json
[27, record.as_json] +
(type.nil? ? [] : [type.as_json])
end
|
#normalize ⇒ Object
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/dhall/normalize.rb', line 285
def normalize
normalized = super
unless [Record, EmptyRecord].include?(normalized.record.class)
return normalized
end
List.of(*normalized.record.to_h.to_a.map do |(k, v)|
k = Text.new(value: k)
Record.new(record: { "mapKey" => k, "mapValue" => v })
end, type: normalized.type&.argument)
end
|