Sha256: 41e9f0c594d626910c2b7b7da468a62becddaf243703ae06ecd68cc7f18ed4b6

Contents?: true

Size: 931 Bytes

Versions: 3

Compression:

Stored size: 931 Bytes

Contents

class MasterLoader
  include Singleton
  attr_accessor_nn :raw_table_load_order, :db_ops, :block_size
  fattr(:raw_table_delete_order) { raw_table_load_order.reverse }
  fattr(:tables_in_load_order) do
    raw_table_load_order.map { |x| table_hash[x.to_s] }
  end
  fattr(:tables_in_delete_order) do
    raw_table_delete_order.map { |x| table_hash[x.to_s] }
  end
  fattr(:table_hash) { {} }
  def add(tl)
    self.table_hash[tl.table_name.to_s] = tl
  end
  def delete_rows!
    tables_in_delete_order.each { |t| t.manager.delete_rows! }
  end
  def load_rows!
    tables_in_load_order.each { |t| t.loader.load! }
  end
  def run!
    tables_in_load_order.each do |t| 
      t.loader.block_size = block_size 
    end
    tm("MasterLoader run") do
      connect!
      delete_rows!
      load_rows!
    end
  end
  def connect!
    ActiveRecord::Base.establish_connection(db_ops)
    Dataload.log "Established Connection"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
GFunk911-dataload-0.8.0 lib/dataload/master_loader.rb
GFunk911-dataload-0.8.1 lib/dataload/master_loader.rb
GFunk911-dataload-0.8.2 lib/dataload/master_loader.rb