Class: ImageOptim::CachePath

Inherits:
Path
  • Object
show all
Defined in:
lib/image_optim/cache_path.rb

Overview

ImageOptiom::Path with a non self destructing #replace method

Constant Summary

Constants inherited from Path

Path::NULL

Instance Method Summary collapse

Methods inherited from Path

convert, #copy, #copy_metadata, #image_format, #move, #temp_path

Instance Method Details

#replace(dst) ⇒ Object

Atomic replace dst with self



7
8
9
10
11
12
13
14
# File 'lib/image_optim/cache_path.rb', line 7

def replace(dst)
  dst = self.class.new(dst)
  dst.temp_path(dst.dirname) do |temp|
    copy(temp)
    dst.(temp)
    temp.rename(dst.to_s)
  end
end