Class: Dragonfly::ActiveRecord::Store
- Inherits:
-
Object
- Object
- Dragonfly::ActiveRecord::Store
- Defined in:
- lib/dragonfly-activerecord/store.rb
Instance Method Summary collapse
- #destroy(uid) ⇒ Object
- #read(uid) ⇒ Object
-
#write(temp_object, opts = {}) ⇒ Object
temp_object
should respond todata
andmeta
.
Instance Method Details
#destroy(uid) ⇒ Object
28 29 30 |
# File 'lib/dragonfly-activerecord/store.rb', line 28 def destroy(uid) File.destroy(uid.to_i) end |
#read(uid) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dragonfly-activerecord/store.rb', line 20 def read(uid) file = File.where(id: uid.to_i).first return nil if file.nil? file.update_column(:accessed_at, Time.now) [ file.data, file. ] end |
#write(temp_object, opts = {}) ⇒ Object
temp_object
should respond to data
and meta
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dragonfly-activerecord/store.rb', line 9 def write(temp_object, opts={}) temp_object.file do |fd| File.new.tap do |file| file. = temp_object. file.data = fd file.save! return file.id.to_s end end end |