Module: DirectWave::Uploader::Paths

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/directwave/uploader/paths.rb

Instance Method Summary collapse

Instance Method Details

#default_urlObject



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

Returns:

  • (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_filenameObject



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_keyObject



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