Class: Hyrax::Transactions::Steps::DeleteAllFileMetadata
- Inherits:
-
Object
- Object
- Hyrax::Transactions::Steps::DeleteAllFileMetadata
- Defined in:
- lib/hyrax/transactions/steps/delete_all_file_metadata.rb
Overview
Deletes a resource from the persister, returning a ‘Dry::Monads::Result` (`Success`|`Failure`).
Instance Method Summary collapse
- #call(resource) ⇒ Dry::Monads::Result
-
#initialize(query_service: Hyrax.query_service, persister: Hyrax.persister, publisher: Hyrax.publisher) ⇒ DeleteAllFileMetadata
constructor
A new instance of DeleteAllFileMetadata.
Constructor Details
#initialize(query_service: Hyrax.query_service, persister: Hyrax.persister, publisher: Hyrax.publisher) ⇒ DeleteAllFileMetadata
Returns a new instance of DeleteAllFileMetadata.
17 18 19 20 21 |
# File 'lib/hyrax/transactions/steps/delete_all_file_metadata.rb', line 17 def initialize(query_service: Hyrax.query_service, persister: Hyrax.persister, publisher: Hyrax.publisher) @persister = persister @query_service = query_service @publisher = publisher end |
Instance Method Details
#call(resource) ⇒ Dry::Monads::Result
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hyrax/transactions/steps/delete_all_file_metadata.rb', line 28 def call(resource) return Failure(:resource_not_persisted) unless resource.persisted? @query_service.custom_queries.find_files(file_set: resource).each do || return Failure[:failed_to_delete_file_metadata, .id] unless Hyrax::Transactions::Container['file_metadata.destroy'] .call() .success? rescue ::Ldp::Gone nil end Success(resource) end |