Class: SdrClient::RedesignedClient::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/redesigned_client/metadata.rb

Overview

Build an object and then deposit it

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apo:, basepath:, source_id:, **options) ⇒ Metadata

Returns a new instance of Metadata.

Parameters:

  • apo (String)

    object ID (druid) of the admin policy/APO

  • basepath (String)

    the base path of the files (to make relative paths absolute)

  • source_id (String)

    source ID

  • options (Hash)

    optional parameters

Options Hash (**options):

  • files (Array<String>)

    a list of relative filepaths to upload

  • files_metadata (Hash<String, Hash<String, String>>)

    file name, hash of additional file metadata



17
18
19
20
21
22
# File 'lib/sdr_client/redesigned_client/metadata.rb', line 17

def initialize(apo:, basepath:, source_id:, **options)
  @apo = apo
  @basepath = basepath
  @source_id = source_id
  @options = options
end

Class Method Details

.depositObject



7
8
9
# File 'lib/sdr_client/redesigned_client/metadata.rb', line 7

def self.deposit(...)
  new(...).deposit
end

Instance Method Details

#depositObject

rubocop:disable Metrics/MethodLength



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sdr_client/redesigned_client/metadata.rb', line 24

def deposit # rubocop:disable Metrics/MethodLength
   = SdrClient::RedesignedClient::StructuralMetadataBuilder.build(
    files: files, files_metadata: , basepath: basepath
  )
  request_builder = SdrClient::RedesignedClient::RequestBuilder.new(
    apo: apo,
    source_id: source_id,
    files_metadata: ,
    **options
  )
  client.deposit_model(
    model: request_builder.to_cocina,
    basepath: basepath,
    files: files,
    accession: accession,
    request_builder: request_builder,
    **options
  )
end