lib/psulib_traject/macros/subjects.rb
# A set of custom traject macros (extractors and normalizers)
# For the hierarchical subject display
#
# Split with em dash along v,x,y,z
A set of custom traject macros (extractors and normalizers)
For the hierarchical subject display

Split with em dash along v,x,y,z
A set of custom traject macros ( extractors and normalizers ) For the hierarchical subject display Split with em dash along v x y z
def process_subject_hierarchy(fields)
    lambda do |record, accumulator|
      return unless record.is_a? MARC::Record
      subjects = []
      Traject::MarcExtractor.cached(fields).collect_matching_lines(record) do |field, spec, extractor|
        extracted_subjects = extract_subjects(field, spec, extractor)
        unless extracted_subjects.empty?
          subjects << PsulibTraject::SubjectHeading.new(extracted_subjects)
        end
      end
      accumulator.replace(
        subjects
          .map(&:value)
          .uniq
      )
    end
  end
def process_subject_hierarchy ( fields ) lambda do | record , accumulator | return unless record . is_a? MARC :: Record subjects = [ ] Traject :: MarcExtractor . cached ( fields ) . collect_matching_lines ( record ) do | field , spec , extractor | extracted_subjects = extract_subjects ( field , spec , extractor ) unless extracted_subjects . empty? subjects << PsulibTraject :: SubjectHeading . new ( extracted_subjects ) end end accumulator . replace ( subjects . map ( & :value ) . uniq ) end end
A set of custom traject macros (extractors and normalizers)
For the hierarchical subject display
A set of custom traject macros ( extractors and normalizers ) For the hierarchical subject display
fields