Class: Hydra::Works::AddExternalFileToFileSet
- Inherits:
-
Object
- Object
- Hydra::Works::AddExternalFileToFileSet
- Defined in:
- lib/hydra/works/services/add_external_file_to_file_set.rb
Defined Under Namespace
Classes: Updater, VersioningUpdater
Class Method Summary collapse
-
.call(file_set, external_file_url, type, opts = {}) ⇒ Object
Adds a file to the file_set.
Class Method Details
.call(file_set, external_file_url, type, opts = {}) ⇒ Object
Adds a file to the file_set
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hydra/works/services/add_external_file_to_file_set.rb', line 11 def self.call(file_set, external_file_url, type, opts = {}) fail ArgumentError, 'supplied object must be a file set' unless file_set.file_set? update_existing = opts.fetch(:update_existing, true) versioning = opts.fetch(:versioning, true) filename = opts.fetch(:filename, external_file_url) # TODO: required as a workaround for https://github.com/projecthydra/active_fedora/pull/858 file_set.save unless file_set.persisted? updater_class = versioning ? VersioningUpdater : Updater updater = updater_class.new(file_set, type, update_existing) status = updater.update(external_file_url, filename) status ? file_set : false end |