class Anschel::Store
Public Class Methods
new(path, log)
click to toggle source
# File lib/anschel/store.rb, line 6 def initialize path, log @path = path || '/tmp/anschel.db' @hash = nil if File.exist? @path @hash = JrJackson::Json.load \ File.read(@path), symbolize_keys: true end @hash ||= {} log.info event: 'stats-loaded' end
Public Instance Methods
[](k ;)
click to toggle source
# File lib/anschel/store.rb, line 17 def [] k ; @hash[k] end
[]=(k,v ;)
click to toggle source
# File lib/anschel/store.rb, line 19 def []= k,v ; @hash[k] = v ; save end
save()
click to toggle source
# File lib/anschel/store.rb, line 21 def save File.open(@path, 'w') do |f| f.puts JrJackson::Json.dump(@hash) end end