Module: Dhall::Operator::FetchFromMerge
- Included in:
- RecursiveRecordMerge, RightBiasedRecordMerge
- Defined in:
- lib/dhall/ast.rb
Instance Method Summary collapse
Instance Method Details
#fetch(selector) ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/dhall/ast.rb', line 368 def fetch(selector) first = public_send(self.class::FETCH1K) second = public_send(self.class::FETCH2K) if first.is_a?(Record) first.fetch(selector) { second.fetch(selector) } elsif second.is_a?(Record) fetch_second_record(first, second, selector) else super end end |
#fetch_second_record(first, second, selector) ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/dhall/ast.rb', line 355 def fetch_second_record(first, second, selector) rec = self.class.new( self.class::FETCH2K => second.slice(selector), self.class::FETCH1K => first ).normalize if rec.class == self.class RecordSelection.new(record: rec, selector: selector) else rec.fetch(selector) end end |