Class: DbBackupTool::Dumper
- Inherits:
-
Object
- Object
- DbBackupTool::Dumper
- Defined in:
- lib/db_backup_tool/dumper.rb
Instance Method Summary collapse
- #batch_size ⇒ Object
- #dump(io) ⇒ Object
-
#initialize(table, options = {}) ⇒ Dumper
constructor
A new instance of Dumper.
Constructor Details
#initialize(table, options = {}) ⇒ Dumper
Returns a new instance of Dumper.
4 5 6 |
# File 'lib/db_backup_tool/dumper.rb', line 4 def initialize(table, = {}) @table, @options = table, .dup end |
Instance Method Details
#batch_size ⇒ Object
16 17 18 |
# File 'lib/db_backup_tool/dumper.rb', line 16 def batch_size @options[:batch_size] || 1000 end |
#dump(io) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/db_backup_tool/dumper.rb', line 8 def dump(io) csv = CSV.new(io, headers: true, write_headers: true) csv << @table.column_names @table.each_record(batch_size) do |record| csv << record.values_at(*(@table.column_names)) end end |