Module: Paperclip::Storage::Tmp
- Defined in:
- lib/paperclip/storage/tmp.rb,
lib/paperclip-storage-tmp/version.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
-
.clear ⇒ Object
Deletes the temporary files and releases references to them.
- .fs ⇒ Object
Instance Method Summary collapse
- #exists?(style_name = default_style) ⇒ Boolean
- #flush_deletes ⇒ Object
- #flush_writes ⇒ Object
- #to_file(style_name = default_style) ⇒ Object
Class Method Details
.clear ⇒ Object
Deletes the temporary files and releases references to them
9 10 11 12 |
# File 'lib/paperclip/storage/tmp.rb', line 9 def self.clear fs.each_value {|f| f.close! } @fs = nil end |
.fs ⇒ Object
4 5 6 |
# File 'lib/paperclip/storage/tmp.rb', line 4 def self.fs @fs ||= {} end |
Instance Method Details
#exists?(style_name = default_style) ⇒ Boolean
14 15 16 |
# File 'lib/paperclip/storage/tmp.rb', line 14 def exists?(style_name = default_style) Tmp.fs.key?(path(style_name)) end |
#flush_deletes ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/paperclip/storage/tmp.rb', line 36 def flush_deletes @queued_for_delete.each do |path| if file = Tmp.fs.delete(path) file.close! end end @queued_for_delete = [] end |
#flush_writes ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/paperclip/storage/tmp.rb', line 27 def flush_writes @queued_for_write.each do |style_name, file| Tmp.fs[path(style_name)] = to_tempfile(file) end after_flush_writes @queued_for_write = {} end |
#to_file(style_name = default_style) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/paperclip/storage/tmp.rb', line 18 def to_file(style_name = default_style) if @queued_for_write[style_name] @queued_for_write[style_name].rewind @queued_for_write[style_name] elsif exists?(style_name) File.new(Tmp.fs[path(style_name)].path, 'rb') end end |