Class: Hyrax::Transactions::Steps::AddFileSets

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/transactions/steps/add_file_sets.rb

Overview

Adds a Hyrax::FileSet

Instance Method Summary collapse

Constructor Details

#initialize(handler: Hyrax::WorkUploadsHandler) ⇒ AddFileSets

Returns a new instance of AddFileSets.

Parameters:

  • handler (Class) (defaults to: Hyrax::WorkUploadsHandler)

Since:

  • 2.4.0


16
17
18
# File 'lib/hyrax/transactions/steps/add_file_sets.rb', line 16

def initialize(handler: Hyrax::WorkUploadsHandler)
  @handler = handler
end

Instance Method Details

#call(obj, uploaded_files: [], file_set_params: []) ⇒ Dry::Monads::Result

Parameters:

  • obj (Hyrax::Work)
  • uploaded_files (Enumerable<UploadedFile>) (defaults to: [])
  • file_set_params (Enumerable<Hash>) (defaults to: [])

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0


26
27
28
29
30
31
32
# File 'lib/hyrax/transactions/steps/add_file_sets.rb', line 26

def call(obj, uploaded_files: [], file_set_params: [])
  if @handler.new(work: obj).add(files: uploaded_files, file_set_params: file_set_params).attach
    Success(obj)
  else
    Failure[:failed_to_attach_file_sets, uploaded_files]
  end
end