Sha256: c7334735d631a79781c942e440d444b079e7194c2d945362e2e93eb4a72053f0
Contents?: true
Size: 722 Bytes
Versions: 42
Compression:
Stored size: 722 Bytes
Contents
# frozen_string_literal: true require 'forwardable' module Dyndnsd class Database extend Forwardable def_delegators :@db, :[], :[]=, :each, :has_key? # @param db_file [String] def initialize(db_file) @db_file = db_file end # @return [void] def load if File.file?(@db_file) @db = JSON.parse(File.read(@db_file, mode: 'r')) else @db = {} end @db_hash = @db.hash end # @return [void] def save Helper.span('database_save') do |_span| File.open(@db_file, 'w') { |f| JSON.dump(@db, f) } @db_hash = @db.hash end end # @return [Boolean] def changed? @db_hash != @db.hash end end end
Version data entries
42 entries across 42 versions & 1 rubygems
Version | Path |
---|---|
dyndnsd-2.3.0 | lib/dyndnsd/database.rb |
dyndnsd-2.2.0 | lib/dyndnsd/database.rb |