Module: SQLMonkey

Extended by:
SQLMonkey
Included in:
SQLMonkey
Defined in:
lib/dumper.rb

Instance Method Summary collapse

Instance Method Details

#harvest(model, baton) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/dumper.rb', line 32

def harvest(model, baton)
  bananas = []
  if baton[:add_deletes]
    bananas << "DELETE FROM #{model.class.quoted_table_name} WHERE #{model.connection.quote_column_name(model.class.primary_key)} = #{model.quoted_id}"
  end
  bananas << "INSERT INTO #{model.class.quoted_table_name} " +
    "(#{model.send(:quoted_column_names).join(', ')}) "  +
    "VALUES(#{model.send(:attributes_with_quotes).values.join(', ')})"
  bananas
end

#sort_out_bananas(bananas) ⇒ Object



43
44
45
# File 'lib/dumper.rb', line 43

def sort_out_bananas(bananas)
  bananas.join(";\n")
end