Class: YDD::YamlDB::Dump

Inherits:
SerializationHelper::Dump show all
Defined in:
lib/ydd/yaml_db.rb

Class Method Summary collapse

Methods inherited from SerializationHelper::Dump

after_table, before_table, dump, dump_table, each_table_page, table_column_names, table_record_count, tables

Class Method Details

.dump_table_columns(io, table) ⇒ Object



30
31
32
33
# File 'lib/ydd/yaml_db.rb', line 30

def self.dump_table_columns(io, table)
  io.write("\n")
  io.write({ table => { 'columns' => table_column_names(table) } }.to_yaml)
end

.dump_table_records(io, table) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/ydd/yaml_db.rb', line 35

def self.dump_table_records(io, table)
  table_record_header(io)

  column_names = table_column_names(table)

  each_table_page(table) do |records|
    rows = SerializationHelper::Utils.unhash_records(records, column_names)
    io.write(YamlDB::Utils.chunk_records(records))
  end
end

.table_record_header(io) ⇒ Object



46
47
48
# File 'lib/ydd/yaml_db.rb', line 46

def self.table_record_header(io)
  io.write("  records: \n")
end