Sha256: b890539df682d1811859607711331245254cf3d8f3cf08ff79db274afa21e84d
Contents?: true
Size: 685 Bytes
Versions: 1
Compression:
Stored size: 685 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={}) File.transaction do file = File.create!(metadata: temp_object.meta) file.data = temp_object.data file.save! return file.id.to_s end end def read(uid) file = File.find(uid.to_i) file.update_attributes!(accessed_at: Time.now) [ file.data, file.metadata ] rescue ActiveRecord::RecordNotFound nil end def destroy(uid) File.destroy(uid.to_i) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dragonfly-activerecord-0.0.1 | lib/dragonfly-activerecord/store.rb |