Module: ContentAddressableFile::ActsAsUploadedFile::ClassMethods
- Defined in:
- lib/content_addressable_file/acts_as_uploaded_file.rb
Instance Attribute Summary collapse
-
#storages ⇒ Object
Returns the value of attribute storages.
Instance Method Summary collapse
-
#register_read_only_storage(*storage) ⇒ Object
Same as #register_storage, but only forwards read only methods.
-
#register_storage(*storage) ⇒ Object
Registers a storage to be used with content-addressable file.
-
#reset ⇒ Object
Removes all registered storages.
Instance Attribute Details
#storages ⇒ Object
Returns the value of attribute storages.
189 190 191 |
# File 'lib/content_addressable_file/acts_as_uploaded_file.rb', line 189 def storages @storages end |
Instance Method Details
#register_read_only_storage(*storage) ⇒ Object
Same as #register_storage, but only forwards read only methods.
207 208 209 210 211 |
# 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) ⇒ Object
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.
201 202 203 204 |
# 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 ⇒ Object
Removes all registered storages
214 215 216 217 |
# File 'lib/content_addressable_file/acts_as_uploaded_file.rb', line 214 def reset self.storages = Set.new(storages).clear self end |