Sha256: f1f045020ff1bfc1401a03bf03276e2f9577ae5d8da9ac46a08320a6b1d7ead3
Contents?: true
Size: 704 Bytes
Versions: 2
Compression:
Stored size: 704 Bytes
Contents
require 'dragonfly-activerecord' require 'dragonfly-activerecord/file' require 'active_record' module Dragonfly::ActiveRecord class Store # +temp_object+ should respond to +data+ and +meta+ def write(temp_object, opts={}) temp_object.file do |fd| File.new.tap do |file| file.metadata = temp_object.meta file.data = fd file.save! return file.id.to_s end end end 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.metadata ] end def destroy(uid) File.destroy(uid.to_i) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dragonfly-activerecord-1.0.0 | lib/dragonfly-activerecord/store.rb |
dragonfly-activerecord-0.1.0 | lib/dragonfly-activerecord/store.rb |