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.



158
159
160
161
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 158

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

Instance Method Details

#<<(v) ⇒ Object



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

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

#flush(value = @buffered_rows) ⇒ Object



167
168
169
170
171
172
173
174
175
176
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 167

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