Class: Paperdragon::Paperclip::Uid

Inherits:
Object
  • Object
show all
Defined in:
lib/paperdragon/paperclip.rb

Overview

Compute a UID to be compatible with paperclip. This class is meant to be subclassed so you can write your specific file path. Immutable

Defined Under Namespace

Classes: HashKey, IdPartition

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Uid

“/system/:class/:attachment/:id_partition/:style/:filename”



13
14
15
16
17
18
19
20
21
22
# 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

Class Method Details

.from(options) ⇒ Object



8
9
10
# File 'lib/paperdragon/paperclip.rb', line 8

def self.from(options)
  new(options).call
end

Instance Method Details

#callObject



24
25
26
27
28
# 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