Sha256: 847530a286b608f9b06515c46f5fa3b53bbd60bbef87259bc1e99af9209c83e3
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
module Watchdocs module Rails module Store 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.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
watchdocs-rails-0.3.1 | lib/watchdocs/rails/buffer/file_buffer.rb |
watchdocs-rails-0.3.0 | lib/watchdocs/rails/buffer/file_buffer.rb |