module KeyStore
Constants
- VERSION
Attributes
file_path[R]
mtime[RW]
Public Class Methods
delete!(name)
click to toggle source
# File lib/key_store.rb, line 39 def delete!(name) store.transaction { |f| f.delete(name.to_s) } end
exists?(name)
click to toggle source
# File lib/key_store.rb, line 31 def exists?(name) !!(store.transaction { |f| f.root?(name.to_s) }) end
find(name)
click to toggle source
# File lib/key_store.rb, line 35 def find(name) exists?(name) ? KeyStore::Key.new(name) : nil end
set_file_path(value)
click to toggle source
# File lib/key_store.rb, line 13 def set_file_path(value) @file_path = value end
store()
click to toggle source
# File lib/key_store.rb, line 17 def store if @store.nil? || modified? Mutex.new.synchronize do @store = begin raise "file_path not set" if file_path.nil? FileUtils.touch(file_path) unless File.exists?(file_path) self.mtime = File.mtime(file_path) YAML::Store.new(file_path, true) end end end @store end
Private Class Methods
modified?()
click to toggle source
# File lib/key_store.rb, line 47 def modified? return true if mtime.nil? || !File.exists?(file_path) File.mtime(file_path) != mtime end