module Moneta::File::Implementation
Public Instance Methods
[](key)
click to toggle source
# File lib/moneta/file.rb, line 56 def [](key) if ::File.exist?(path(key)) Marshal.load(::File.read(path(key))) end end
[]=(key, value)
click to toggle source
# File lib/moneta/file.rb, line 62 def []=(key, value) ::File.open(path(key), "w") do |file| contents = Marshal.dump(value) file.puts(contents) end end
clear()
click to toggle source
# File lib/moneta/file.rb, line 76 def clear FileUtils.rm_rf(@directory) FileUtils.mkdir(@directory) end
delete(key)
click to toggle source
# File lib/moneta/file.rb, line 69 def delete(key) value = self[key] FileUtils.rm(path(key)) value rescue Errno::ENOENT end
key?(key)
click to toggle source
# File lib/moneta/file.rb, line 50 def key?(key) ::File.exist?(path(key)) end
Also aliased as: has_key?
Private Instance Methods
path(key)
click to toggle source
# File lib/moneta/file.rb, line 82 def path(key) ::File.join(@directory, key.to_s) end