Class: Dhall::Merge
- 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
#&, #*, #+, #as_dhall, #cache_key, #call, #concat, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #fusion, #merge, #resolve, #shift, #slice, #substitute, #to_cbor, #to_proc, #to_s, #|
Class Method Details
.decode(record, input, type = nil) ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/dhall/binary.rb', line 106
def self.decode(record, input, type=nil)
new(
record: Dhall.decode(record),
input: Dhall.decode(input),
type: type.nil? ? nil : Dhall.decode(type)
)
end
|
Instance Method Details
#as_json ⇒ Object
553
554
555
556
|
# File 'lib/dhall/ast.rb', line 553
def as_json
[6, record.as_json, input.as_json] +
(type.nil? ? [] : [type.as_json])
end
|
#normalize ⇒ Object
269
270
271
272
273
274
275
276
277
278
|
# File 'lib/dhall/normalize.rb', line 269
def normalize
normalized = super
if normalized.record.is_a?(Record) && normalized.input.is_a?(Union)
fetched = normalized.record.fetch(normalized.input.tag)
value = normalized.input.value
value.nil? ? fetched : fetched.call(value)
else
normalized
end
end
|