Class: YamlDb::Load

Inherits:
SerializationHelper::Load show all
Defined in:
lib/ironmine_yaml_db.rb

Class Method Summary collapse

Methods inherited from SerializationHelper::Load

load, load_records, load_table, reset_pk_sequence!, truncate_table

Class Method Details

.load_documents(io, truncate = true) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ironmine_yaml_db.rb', line 60

def self.load_documents(io, truncate = true)
  YAML.load_documents(io) do |ydoc|
    ydoc.keys.each do |table_name|
      next if ydoc[table_name].nil?
      if ActiveRecord::Base.connection.table_exists?(table_name)
        load_table(table_name, ydoc[table_name], truncate)
      else
        puts "Table: #{table_name} is not exists."
      end
    end
  end
end