module ContentAddressableFile::ActsAsUploadedFile::ClassMethods

Attributes

storages[RW]

Public Instance Methods

register_read_only_storage(*storage) click to toggle source

Same as register_storage, but only forwards read only methods.

# File lib/content_addressable_file/acts_as_uploaded_file.rb, line 207
def register_read_only_storage(*storage)
  read_only = Array(storage).map { |s| ReadOnlyStorage.new(s) }
  self.storages = Set.new(storages).merge(read_only)
  self
end
register_storage(*storage) click to toggle source

Registers a storage to be used with content-addressable file. All shrine storages are supported by default, as is any duck type that responds to Storage#open(content-addressable-hash) and Storage#exists?(hash).

Additional functionality needs Storage#url(hash), Storage#delete(hash) and Storage#download(hash).

When a content-addressable file is deleted, it's deleted from all registered storages. use register_read_only_storage to prevent deletion.

# File lib/content_addressable_file/acts_as_uploaded_file.rb, line 201
def register_storage(*storage)
  self.storages = Set.new(storages).merge(Array(storage))
  self
end
reset() click to toggle source

Removes all registered storages

# File lib/content_addressable_file/acts_as_uploaded_file.rb, line 214
def reset
  self.storages = Set.new(storages).clear
  self
end