method
writing
v5.2.3 -
Show latest stable
- Class:
ActiveSupport::EncryptedFile
writing(contents)private
No documentation available.
# File activesupport/lib/active_support/encrypted_file.rb, line 59
def writing(contents)
tmp_file = "#{Process.pid}.#{content_path.basename.to_s.chomp('.enc')}"
tmp_path = Pathname.new File.join(Dir.tmpdir, tmp_file)
tmp_path.binwrite contents
yield tmp_path
updated_contents = tmp_path.binread
write(updated_contents) if updated_contents != contents
ensure
FileUtils.rm(tmp_path) if tmp_path.exist?
end