Sha256: 76d1352a7af90c639032e39f3c6fcfa78e0b615f528afca9ca724b32dcf4070f
Contents?: true
Size: 697 Bytes
Versions: 23
Compression:
Stored size: 697 Bytes
Contents
class SingleUseLink < ActiveRecord::Base attr_accessible :downloadKey, :expires, :itemId, :path def self.create_show(item_id) create_path(item_id, Sufia::Engine.routes.url_helpers.generic_file_path(item_id) ) end def self.create_download(item_id) create_path(item_id, Sufia::Engine.routes.url_helpers.download_path(item_id) ) end def expired? now = DateTime.now return (now > expires) end protected def self.create_path(itemId, path) expires = DateTime.now.advance(hours:24) key = Digest::SHA2.new << DateTime.now.to_f.to_s return create({downloadKey:key.to_s, expires:expires, path:path, itemId:itemId} ) end end
Version data entries
23 entries across 23 versions & 2 rubygems
Version | Path |
---|---|
sufia-0.0.2 | app/models/single_use_link.rb |
sufia-0.0.1 | app/models/single_use_link.rb |
sufia-0.0.1.pre2 | app/models/single_use_link.rb |