Class: CanvasSync::Importers::BulkImporter::RowBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_sync/importers/bulk_importer.rb

Direct Known Subclasses

UserRowBuffer

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ RowBuffer

Returns a new instance of RowBuffer.



161
162
163
164
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 161

def initialize(&block)
  @flush_out = block
  @buffered_rows = []
end

Instance Method Details

#<<(v) ⇒ Object



166
167
168
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 166

def <<(v)
  @buffered_rows << v
end

#flush(value = @buffered_rows) ⇒ Object



170
171
172
173
174
175
176
177
178
179
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 170

def flush(value = @buffered_rows)
  if value.is_a?(Array)
    value.each do |v|
      @flush_out.call(v)
    end
  else
    @flush_out.call(value)
  end
  @buffered_rows = []
end