Module: Macros::DlmeMarc

Defined in:
lib/macros/dlme_marc.rb

Overview

Macros that change some of Traject's MARC behaviors for the sake of DLME.

Instance Method Summary collapse

Instance Method Details

#extract_role(marc_field, role) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/macros/dlme_marc.rb', line 8

def extract_role(marc_field, role)
  lambda do |record, accumulator|
    record.each_by_tag(marc_field) do |field|
      if role == 'creator'
        accumulator.concat [field.value] if %w[creator author cre aut].include?(field['e'])
      elsif role == 'contributor'
        accumulator.concat [field.value] unless %w[creator author cre aut].include?(field['e'])
      end
    end
  end
end

#marc_type_to_edmObject


20
21
22
23
24
25
26
# File 'lib/macros/dlme_marc.rb', line 20

def marc_type_to_edm
  lambda { |record, accumulator, _context|
    leader06 = record.leader.byteslice(6)
    edm_types = TrajectPlus::Extraction.apply_extraction_options(leader06, translation_map: 'types')
    accumulator.concat(edm_types)
  }
end