Sha256: c8f2c71a2f58aaedd3640cf3886d9fcb5241e287e649ad0734f56dd9944fc03e
Contents?: true
Size: 959 Bytes
Versions: 1
Compression:
Stored size: 959 Bytes
Contents
module Hydra::Works class UploadFileToGenericFile def self.call(object, path, additional_services=[], replace=false) raise ArgumentError, "supplied object must be a generic file" unless Hydra::Works.generic_file?(object) raise ArgumentError, "supplied path must be a string" unless path.is_a?(String) raise ArgumentError, "supplied path to file does not exist" unless ::File.exists?(path) if object.original_file.nil? || object.original_file.new_record? Hydra::Works::AddOriginalFile.call(object, path) else if replace Hydra::Works::AddOriginalFile.call(object, path, replace) else Hydra::Works::AddVersionedOriginalFile.call(object, path) end end object.save object.reload # Call any additional services additional_services.each do |service| service.call(object) end object.save object end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hydra-works-0.0.1 | lib/hydra/works/services/generic_file/upload_file.rb |