Method: ImageOptim::ImagePath#replace

Defined in:
lib/image_optim/image_path.rb

#replace(src) ⇒ Object

Atomic replace src with self



41
42
43
44
45
46
47
48
49
# File 'lib/image_optim/image_path.rb', line 41

def replace(src)
  src = self.class.new(src)
  src.temp_path(src.dirname) do |temp|
    src.copy(temp)
    temp.write(read)
    temp.rename(src.to_s)
    unlink
  end
end