Sha256: 8093f26351a8e3e2d5b5814bddc8ec32750eb33ccb3def27fe35eeb1e4c5d646
Contents?: true
Size: 518 Bytes
Versions: 24
Compression:
Stored size: 518 Bytes
Contents
require 'jrjackson' module Anschel class Store 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 def [] k ; @hash[k] end def []= k,v ; @hash[k] = v ; save end def save File.open(@path, 'w') do |f| f.puts JrJackson::Json.dump(@hash) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems