Class: FileUploadCache::CachedFile
- Inherits:
-
Object
- Object
- FileUploadCache::CachedFile
- Defined in:
- app/models/file_upload_cache/cached_file.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#original_filename ⇒ Object
Returns the value of attribute original_filename.
-
#read ⇒ Object
Returns the value of attribute read.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ CachedFile
constructor
A new instance of CachedFile.
Constructor Details
#initialize(attributes) ⇒ CachedFile
5 6 7 8 9 |
# File 'app/models/file_upload_cache/cached_file.rb', line 5 def initialize(attributes) attributes.each do |k, v| self.send("#{k}=", v) end end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'app/models/file_upload_cache/cached_file.rb', line 3 def content_type @content_type end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/models/file_upload_cache/cached_file.rb', line 3 def id @id end |
#original_filename ⇒ Object
Returns the value of attribute original_filename.
3 4 5 |
# File 'app/models/file_upload_cache/cached_file.rb', line 3 def original_filename @original_filename end |
#read ⇒ Object
Returns the value of attribute read.
3 4 5 |
# File 'app/models/file_upload_cache/cached_file.rb', line 3 def read @read end |
Class Method Details
.find(id) ⇒ Object
23 24 25 |
# File 'app/models/file_upload_cache/cached_file.rb', line 23 def self.find(id) FileUploadCache.file_cache.read("FileUploadCache::#{id}") end |
.store(image) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/file_upload_cache/cached_file.rb', line 11 def self.store(image) id = UUID.generate(:compact) cached_file = self.new(:read => image.read, :original_filename => image.respond_to?(:original_filename) ? image.original_filename : nil, :id => id, :content_type => image.respond_to?(:content_type) ? image.content_type : nil) FileUploadCache.file_cache.write("FileUploadCache::#{id}", cached_file) cached_file end |