class Dyndnsd::Database

Public Class Methods

new(db_file) click to toggle source

@param db_file [String]

# File lib/dyndnsd/database.rb, line 12
def initialize(db_file)
  @db_file = db_file
end

Public Instance Methods

changed?() click to toggle source

@return [Boolean]

# File lib/dyndnsd/database.rb, line 35
def changed?
  @db_hash != @db.hash
end
load() click to toggle source

@return [void]

# File lib/dyndnsd/database.rb, line 17
def load
  if File.file?(@db_file)
    @db = JSON.parse(File.read(@db_file, mode: 'r'))
  else
    @db = {}
  end
  @db_hash = @db.hash
end
save() click to toggle source

@return [void]

# File lib/dyndnsd/database.rb, line 27
def save
  Helper.span('database_save') do |_span|
    File.open(@db_file, 'w') { |f| JSON.dump(@db, f) }
    @db_hash = @db.hash
  end
end