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: []) ⇒ Dry::Monads::Result

Parameters:

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0


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

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