Class: CanvasSync::Importers::BulkImporter::RowBuffer
- Inherits:
-
Object
- Object
- CanvasSync::Importers::BulkImporter::RowBuffer
- Defined in:
- lib/canvas_sync/importers/bulk_importer.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(v) ⇒ Object
- #flush(value = @buffered_rows) ⇒ Object
-
#initialize(&block) ⇒ RowBuffer
constructor
A new instance of RowBuffer.
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 |