Class: MiniPaperclip::Storage::Filesystem
- Inherits:
-
Base
- Object
- Base
- MiniPaperclip::Storage::Filesystem
show all
- Defined in:
- lib/mini_paperclip/storage/filesystem.rb
Instance Attribute Summary
Attributes inherited from Base
#attachment, #config, #interpolator
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #interpolate, #path_for, #url_for_read
Instance Method Details
#do_delete_files ⇒ Object
31
32
33
34
35
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 31
def do_delete_files
return if @deletes.empty?
debug("deleting by filesystem #{@deletes}")
FileUtils.rm_f(@deletes)
end
|
#exists?(style) ⇒ Boolean
Also known as:
exist?
22
23
24
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 22
def exists?(style)
File.exist?(file_path(style))
end
|
#file_path(style) ⇒ Object
14
15
16
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 14
def file_path(style)
interpolate(@config.filesystem_path, style)
end
|
#host ⇒ Object
18
19
20
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 18
def host
@config.url_host
end
|
#open(style, &block) ⇒ Object
37
38
39
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 37
def open(style, &block)
File.open(file_path(style), 'r', &block)
end
|
#push_delete_file(style) ⇒ Object
27
28
29
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 27
def push_delete_file(style)
@deletes.push(file_path(style))
end
|
#write(style, file) ⇒ Object
6
7
8
9
10
11
12
|
# 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)
end
|