Class: Hyrax::Transactions::Steps::AddFileSets
- Inherits:
-
Object
- Object
- Hyrax::Transactions::Steps::AddFileSets
- Defined in:
- lib/hyrax/transactions/steps/add_file_sets.rb
Overview
Adds a Hyrax::FileSet
Instance Method Summary collapse
- #call(obj, uploaded_files: [], file_set_params: []) ⇒ Dry::Monads::Result
-
#initialize(handler: Hyrax::WorkUploadsHandler) ⇒ AddFileSets
constructor
A new instance of AddFileSets.
Constructor Details
#initialize(handler: Hyrax::WorkUploadsHandler) ⇒ AddFileSets
Returns a new instance of AddFileSets.
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
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 file_sets = obj.member_ids.map do |member| Hyrax.query_service.find_by(id: member) if Hyrax.query_service.find_by(id: member).is_a? Hyrax::FileSet end Hyrax::LeaseManager.create_or_update_lease_on_members(file_sets, obj) if obj.lease Hyrax::EmbargoManager.(file_sets, obj) if obj. Success(obj) else Failure[:failed_to_attach_file_sets, uploaded_files] end end |