Module: DirectWave::Uploader::Paths
Instance Method Summary collapse
- #default_url ⇒ Object
- #filename(part = nil) ⇒ Object
- #has_store_key? ⇒ Boolean
- #key(version = :original) ⇒ Object
- #original_filename ⇒ Object
- #store_key ⇒ Object
- #store_key=(string) ⇒ Object
- #url(version = :original) ⇒ Object
Instance Method Details
#default_url ⇒ Object
15 |
# File 'lib/directwave/uploader/paths.rb', line 15 def default_url; end |
#filename(part = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/directwave/uploader/paths.rb', line 17 def filename(part=nil) return original_filename unless has_store_key? key_path = store_key.split("/") filename_parts = [] filename = filename_parts.unshift(key_path.pop) unique_key = key_path.pop filename_parts.unshift(unique_key) if unique_key filename_parts.join("/") end |
#has_store_key? ⇒ Boolean
40 41 42 |
# File 'lib/directwave/uploader/paths.rb', line 40 def has_store_key? @store_key.present? && !(@store_key =~ /#{Regexp.escape("${filename}")}\z/) end |
#key(version = :original) ⇒ Object
11 12 13 |
# File 'lib/directwave/uploader/paths.rb', line 11 def key(version=:original) versions[version.to_sym].key end |
#original_filename ⇒ Object
28 29 30 |
# File 'lib/directwave/uploader/paths.rb', line 28 def original_filename model[mounted_as.to_s] if model.respond_to?(mounted_as) end |
#store_key ⇒ Object
36 37 38 |
# File 'lib/directwave/uploader/paths.rb', line 36 def store_key @store_key ||= "#{upload_dir}/#{guid}/${filename}" end |
#store_key=(string) ⇒ Object
32 33 34 |
# File 'lib/directwave/uploader/paths.rb', line 32 def store_key=(string) @store_key = string end |
#url(version = :original) ⇒ Object
7 8 9 |
# File 'lib/directwave/uploader/paths.rb', line 7 def url(version=:original) versions[version.to_sym].url || default_url end |