Sha256: 601d76f78a0bfc34b2b974932ce848cb3ba6fc30cb4ae96c55725f64f49bb339
Contents?: true
Size: 1.05 KB
Versions: 12
Compression:
Stored size: 1.05 KB
Contents
module Watchdocs module Rails module Buffer module FileBuffer class StorageError < StandardError; end class << self def write(content) File.write(path_to_file, content.to_json) path_to_file rescue StandardError => e raise StorageError, e end def read file = File.open(path_to_file, 'r') JSON.parse(file.read) rescue JSON::ParserError [] rescue StandardError => e raise StorageError, e ensure file && file.close end def delete! File.delete(path_to_file) rescue StandardError => e raise StorageError, e end def exists? File.exist?(path_to_file) end private def path_to_file "#{temp_local_path}/reqests.json" end def temp_local_path Rails.configuration.temp_directory end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems