class NewspaperWorks::Ingest::NDNP::ContainerIngester

Ingester for reel/container, given reel source data

and required publication (NewspaperTitle) asset.
Responsibile for creating/finding container, linking
to (parent) publication and (child) pages.

Attributes

opts[RW]
publication[RW]
source[RW]
target[RW]

Public Class Methods

new(source, publication, opts = {}) click to toggle source

Create ingester in context of source reel data, NewspaperTitle @param source [NewspaperWorks::Ingest::NDNP::ContainerIngest] @param publication [NewspaperTitle] Required publication to link to @param opts [Hash]

ingest options, e.g. administrative metadata
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 18
def initialize(source, publication, opts = {})
  @source = source
  @publication = publication
  @opts = opts
  # initially nil, populate w/ NewspaperContainer object via .ingest
  @target = nil
end

Public Instance Methods

find_or_create_container() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 39
def find_or_create_container
  @target = find_container
  create_container if @target.nil?
end
ingest() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 26
def ingest
  find_or_create_container
  link_publication
end

Private Instance Methods

copy_metadata() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 61
def copy_metadata
  reel_number = metadata.reel_number
  @target.identifier = [reel_number]
  @target.title = ["Microform reel (#{reel_number})"]
  copy_fields = [
    :held_by,
    :publication_date_start,
    :publication_date_end
  ]
  copy_fields.each do |fieldname|
    value = metadata.send(fieldname.to_s)
    @target.send("#{fieldname}=", value)
  end
end
create_container() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 54
def create_container
  @target = NewspaperContainer.create
  copy_metadata
  assign_administrative_metadata
  @target.save!
end
find_container() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 50
def find_container
  NewspaperContainer.where(identifier: metadata.reel_number).first
end
metadata() click to toggle source
# File lib/newspaper_works/ingest/ndnp/container_ingester.rb, line 46
def metadata
  @source.metadata
end