Class: Dhall::RecordProjection
- 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, #fusion, #merge, #resolve, #shift, #slice, #substitute, #to_binary, #to_cbor, #to_proc, #to_s, #|
Class Method Details
.decode(record, *selectors) ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/dhall/binary.rb', line 162
def self.decode(record, *selectors)
record = Dhall.decode(record)
if selectors.length == 1 && selectors[0].is_a?(Array)
RecordProjectionByExpression.new(
record: record,
selector: Dhall.decode(selectors[0][0])
)
else
self.for(record, selectors)
end
end
|
.for(record, selectors) ⇒ Object
906
907
908
909
910
911
912
|
# File 'lib/dhall/ast.rb', line 906
def self.for(record, selectors)
if selectors.empty?
EmptyRecordProjection.new(record: record)
else
new(record: record, selectors: selectors)
end
end
|
Instance Method Details
#as_json ⇒ Object
918
919
920
|
# File 'lib/dhall/ast.rb', line 918
def as_json
[10, record.as_json, *selectors]
end
|
#fetch(selector) ⇒ Object
914
915
916
|
# File 'lib/dhall/ast.rb', line 914
def fetch(selector)
record.fetch(selector)
end
|
#normalize ⇒ Object
348
349
350
|
# File 'lib/dhall/normalize.rb', line 348
def normalize
record.normalize.slice(*selectors.sort)
end
|