Class: Gamma::SyncDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/gamma/sync_database.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SyncDatabase

Returns a new instance of SyncDatabase.



2
3
4
5
6
7
8
9
# File 'lib/gamma/sync_database.rb', line 2

def initialize(path)
  @sync_history_path = path
  @database = if File.exists?(@sync_history_path)
                JSON.parse(open(@sync_history_path).read)
              else
                {}
              end
end

Instance Method Details

#saveObject



11
12
13
14
15
# File 'lib/gamma/sync_database.rb', line 11

def save
  open(@sync_history_path, "w") do |io|
    JSON.dump(@database, io)
  end
end