Sha256: c09b946d348adbe13ff285b94c5dc945a2ecc67e4a2e06c1ee24ee8ac9dbb800

Contents?: true

Size: 866 Bytes

Versions: 6

Compression:

Stored size: 866 Bytes

Contents

module Ddr::IngestTools::DdrRdrMigrator
  class WorkNester

    attr_reader :logger, :manifest

    def initialize(logger: nil, manifest:)
      @logger = logger || Logger.new(STDOUT)
      @manifest = manifest
    end

    def call
      nest_works
      manifest
    end

    private

    def nest_works
      add_parent_ark_column
      add_parent_ark_values
    end

    def add_parent_ark_column
      manifest.each do |row|
        row['parent_ark'] = nil
      end
    end

    def add_parent_ark_values
      item_rows.each do |row|
        row['parent_ark'] = collection_ark
      end
    end

    def collection_row
      manifest.find { |row| row['model'] == 'Collection' }
    end

    def item_rows
      manifest.select { |row| row['model'] == 'Item' }
    end

    def collection_ark
      @collection_ark ||= collection_row['ark']
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ddr-ingesttools-0.6.1 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb
ddr-ingesttools-0.6.0 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb
ddr-ingesttools-0.5.0 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb
ddr-ingesttools-0.5.0.rc3 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb
ddr-ingesttools-0.5.0.rc2 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb
ddr-ingesttools-0.5.0.rc1 lib/ddr/ingesttools/ddr_rdr_migrator/work_nester.rb