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

Version Path
anschel-0.7.19 lib/anschel/store.rb
anschel-0.7.18 lib/anschel/store.rb
anschel-0.7.17 lib/anschel/store.rb
anschel-0.7.16 lib/anschel/store.rb
anschel-0.7.15 lib/anschel/store.rb
anschel-0.7.14 lib/anschel/store.rb
anschel-0.7.13 lib/anschel/store.rb
anschel-0.7.12 lib/anschel/store.rb
anschel-0.7.11 lib/anschel/store.rb
anschel-0.7.10 lib/anschel/store.rb
anschel-0.7.9 lib/anschel/store.rb
anschel-0.7.8 lib/anschel/store.rb
anschel-0.7.7 lib/anschel/store.rb
anschel-0.7.6 lib/anschel/store.rb
anschel-0.7.5 lib/anschel/store.rb
anschel-0.7.4 lib/anschel/store.rb
anschel-0.7.3 lib/anschel/store.rb
anschel-0.7.2 lib/anschel/store.rb
anschel-0.7.1 lib/anschel/store.rb
anschel-0.7.0 lib/anschel/store.rb