Sha256: 82448e07ca716c281eda32ed20f1bde5687dcd841d73027234e07788d582ef48
Contents?: true
Size: 583 Bytes
Versions: 9
Compression:
Stored size: 583 Bytes
Contents
require 'oj' require 'multi_json' require 'fileutils' module Hookit class DB DEFAULT_PATH = '/var/db/hookit/db.json' def initialize(path=nil) @path = path || DEFAULT_PATH end def fetch(key) data[key] end def put(key, value) data[key] = value save end def load ::MultiJson.load(::File.read(@path), symbolize_keys: true) rescue {} end def save ::FileUtils.mkdir_p(File.dirname(@path)) ::File.write(@path, ::MultiJson.dump(data)) end def data @data ||= load end end end
Version data entries
9 entries across 9 versions & 2 rubygems