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
29
30
31
32
33
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 29
def do_delete_files
return if @deletes.empty?
debug("deleting by filesystem #{@deletes}")
FileUtils.rm_f(@deletes)
end
|
#exists?(style) ⇒ Boolean
21
22
23
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 21
def exists?(style)
File.exists?(file_path(style))
end
|
#file_path(style) ⇒ Object
13
14
15
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 13
def file_path(style)
interpolate(@config.filesystem_path, style)
end
|
#host ⇒ Object
17
18
19
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 17
def host
@config.url_host
end
|
#open(style, &block) ⇒ Object
35
36
37
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 35
def open(style, &block)
File.open(file_path(style), 'r', &block)
end
|
#push_delete_file(style) ⇒ Object
25
26
27
|
# File 'lib/mini_paperclip/storage/filesystem.rb', line 25
def push_delete_file(style)
@deletes.push(file_path(style))
end
|
#write(style, file) ⇒ Object
6
7
8
9
10
11
|
# 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
end
|