Sha256: d9cb34d69661d252cdfb47541e61dafad659adf342cff80037a19e672ecfd09b

Contents?: true

Size: 1.55 KB

Versions: 7

Compression:

Stored size: 1.55 KB

Contents

require 'traject'
require 'traject/umich_format'

module Traject::UMichFormat::Macros
  def umich_format_code
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc << context.clipboard[:umich_format_obj].bib_format
    end
  end

  def umich_format
    tmap = Traject::TranslationMap.new('umich/format')
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc << tmap[context.clipboard[:umich_format_obj].bib_format]
    end
  end

  def umich_type_codes
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc.concat context.clipboard[:umich_format_obj].types
    end
  end

  def umich_types
    tmap = Traject::TranslationMap.new('umich/format')
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc.concat context.clipboard[:umich_format_obj].types.map{|x| tmap[x]}
    end

  end

  def umich_format_and_type_codes
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc.concat context.clipboard[:umich_format_obj].format_and_types
    end
  end

  def umich_format_and_types
    tmap = Traject::TranslationMap.new('umich/format')
    ->(record, acc, context) do
      context.clipboard[:umich_format_obj] ||= Traject::UMichFormat.new(record)
      acc.concat context.clipboard[:umich_format_obj].format_and_types.map{|x| tmap[x]}
    end
  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
traject_umich_format-0.3.0 lib/traject/umich_format/macros.rb
traject_umich_format-0.2.0 lib/traject/umich_format/macros.rb
traject_umich_format-0.1.4 lib/traject/umich_format/macros.rb
traject_umich_format-0.1.3 lib/traject/umich_format/macros.rb
traject_umich_format-0.1.2 lib/traject/umich_format/macros.rb
traject_umich_format-0.1.1 lib/traject/umich_format/macros.rb
traject_umich_format-0.1.0 lib/traject/umich_format/macros.rb