Module: DBA::YAML
- Defined in:
- lib/dba/yaml.rb
Class Method Summary collapse
Class Method Details
.dump(database, table_name, path) ⇒ Object
5 6 7 8 9 |
# File 'lib/dba/yaml.rb', line 5 def self.dump(database, table_name, path) File.open(path, 'w+') do |io| io.write ::YAML.dump(database[table_name].all.map(&:compact)) end end |
.load(path, database, table_name) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dba/yaml.rb', line 11 def self.load(path, database, table_name) dataset = database[table_name] database.transaction do ::YAML.load_file(path).each do |row| dataset.insert(row) end end end |