Class: SdrClient::Deposit::FileSet

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/deposit/file_set.rb

Overview

This represents the FileSet metadata that we send to the server for doing a deposit

Instance Method Summary collapse

Constructor Details

#initialize(uploads: [], uploads_metadata: {}, files: [], label:) ⇒ FileSet

Returns a new instance of FileSet.

Parameters:

  • uploads (Array) (defaults to: [])
  • uploads_metadata (Hash<String,Hash<String,String>>) (defaults to: {})

    the file level metadata

  • files (Array) (defaults to: [])
  • label (String)


11
12
13
14
15
16
17
18
19
20
# File 'lib/sdr_client/deposit/file_set.rb', line 11

def initialize(uploads: [], uploads_metadata: {}, files: [], label:)
  @label = label
  @files = if !uploads.empty?
             uploads.map do |upload|
               File.new(**file_args(upload, .fetch(upload.filename, {})))
             end
           else
             files
           end
end

Instance Method Details

#as_jsonObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/sdr_client/deposit/file_set.rb', line 22

def as_json
  {
    "type": 'http://cocina.sul.stanford.edu/models/resources/file.jsonld',
    "label": label,
    structural: {
      contains: files.map(&:as_json)
    },
    version: 1
  }
end