Class: Attach::Backends::Abstract
- Inherits:
-
Object
- Object
- Attach::Backends::Abstract
- Defined in:
- lib/attach/backends/abstract.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#delete(attachment) ⇒ Object
Delete the data for the given attachment.
-
#initialize(config = {}) ⇒ Abstract
constructor
A new instance of Abstract.
-
#read(attachment) ⇒ Object
Return the data for the given attachment.
-
#read_multi(attachments) ⇒ Object
Return binaries for a set of files.
-
#url(attachment) ⇒ Object
Return the URL that this attachment can be accessed at.
-
#write(attachment, data) ⇒ Object
Write data for the given attachment.
Constructor Details
#initialize(config = {}) ⇒ Abstract
Returns a new instance of Abstract.
5 6 7 |
# File 'lib/attach/backends/abstract.rb', line 5 def initialize(config = {}) @config = config end |
Instance Method Details
#delete(attachment) ⇒ Object
Delete the data for the given attachment
24 25 |
# File 'lib/attach/backends/abstract.rb', line 24 def delete() end |
#read(attachment) ⇒ Object
Return the data for the given attachment
12 13 |
# File 'lib/attach/backends/abstract.rb', line 12 def read() end |
#read_multi(attachments) ⇒ Object
Return binaries for a set of files. They should be returned as a hash consisting of the attachment ID followed by the data
38 39 40 41 42 |
# File 'lib/attach/backends/abstract.rb', line 38 def read_multi() .compact.each_with_object({}) do |, hash| hash[] = read() end end |
#url(attachment) ⇒ Object
Return the URL that this attachment can be accessed at
30 31 32 |
# File 'lib/attach/backends/abstract.rb', line 30 def url() "#{Attach.asset_host}/attachment/#{.token}/#{.file_name}" end |
#write(attachment, data) ⇒ Object
Write data for the given attachment
18 19 |
# File 'lib/attach/backends/abstract.rb', line 18 def write(, data) end |