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(label:, uploads: [], uploads_metadata: {}, files: [], type_strategy: FileTypeFileSetStrategy) ⇒ FileSet

Returns a new instance of FileSet.

Parameters:

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

    the file level metadata

  • files (Array) (defaults to: [])
  • type_strategy (Class) (defaults to: FileTypeFileSetStrategy)

    (FileTypeFileSetStrategy) a class that helps us determine how to type the fileset



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

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

Instance Method Details

#as_jsonObject



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

def as_json
  {
    type: type_strategy.run(files: files),
    label: label,
    structural: {
      contains: files.map(&:as_json)
    },
    version: 1
  }
end