class Paperdragon::Paperclip::Uid
Compute a UID to be compatible with paperclip. This class is meant to be subclassed so you can write your specific file path. Immutable
Attributes
attachment[R]
class_name[R]
file_name[R]
fingerprint[R]
hash_secret[R]
id[R]
style[R]
updated_at[R]
Public Class Methods
from(options)
click to toggle source
# File lib/paperdragon/paperclip.rb, line 8 def self.from(options) new(options).call end
new(options)
click to toggle source
“/system/:class/:attachment/:id_partition/:style/:filename”
# File lib/paperdragon/paperclip.rb, line 13 def initialize(options) @class_name = options[:class_name] @attachment = options[:attachment] @id = options[:id] @style = options[:style] @updated_at = options[:updated_at] @file_name = options[:file_name] @hash_secret = options[:hash_secret] @fingerprint = options[:fingerprint] # not used in default. end
Public Instance Methods
call()
click to toggle source
# File lib/paperdragon/paperclip.rb, line 24 def call # default: # system/:class/:attachment/:id_partition/:style/:filename "#{root}/#{class_name}/#{attachment}/#{id_partition}/#{hash}/#{style}/#{file_name}" end
Private Instance Methods
hash()
click to toggle source
# File lib/paperdragon/paperclip.rb, line 41 def hash HashKey.call(hash_secret, class_name, attachment, id, style, updated_at) end
id_partition()
click to toggle source
# File lib/paperdragon/paperclip.rb, line 37 def id_partition IdPartition.call(id) end
root()
click to toggle source
# File lib/paperdragon/paperclip.rb, line 33 def root "system" end