Module: DataHandler

Included in:
Codebreaker::Statistic
Defined in:
lib/database/data_handler.rb

Class Method Summary collapse

Class Method Details

.load(file_path) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/database/data_handler.rb', line 4

def self.load(file_path)
  if File.exist?(file_path)
    YAML.safe_load(File.read(file_path), [Symbol], [], true)
  else
    File.open(file_path, 'w+')
    false
  end
end

.save(file_path, object) ⇒ Object



13
14
15
# File 'lib/database/data_handler.rb', line 13

def self.save(file_path, object)
  File.open(file_path, 'w') { |file| file.write(object.to_yaml) }
end