class MiniPaperclip::Storage::Filesystem

Public Instance Methods

do_delete_files() click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 30
def do_delete_files
  return if @deletes.empty?
  debug("deleting by filesystem #{@deletes}")
  FileUtils.rm_f(@deletes)
end
exists?(style) click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 22
def exists?(style)
  File.exists?(file_path(style))
end
file_path(style) click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 14
def file_path(style)
  interpolate(@config.filesystem_path, style)
end
host() click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 18
def host
  @config.url_host
end
open(style, &block) click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 36
def open(style, &block)
  File.open(file_path(style), 'r', &block)
end
push_delete_file(style) click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 26
def push_delete_file(style)
  @deletes.push(file_path(style))
end
write(style, file) click to toggle source
# File lib/mini_paperclip/storage/filesystem.rb, line 6
def write(style, file)
  path = file_path(style)
  debug("writing by filesystem from:#{file.path} to:#{path}")
  FileUtils.mkdir_p(File.dirname(path))
  FileUtils.cp(file.path, path) if file.path != path
  @deletes.delete(path) # cancel deletion if overwrite
end