Class: CanvasSync::Importers::BulkImporter::UserRowBuffer

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

Overview

Ensures that, if a User has multiple rows, one with a SIS ID is preferred. This is mainly to fix issues in legacy apps - the suggested approach for new apps is to sync and use the Pseudonymes table

Instance Method Summary collapse

Methods inherited from RowBuffer

#initialize

Constructor Details

This class inherits a constructor from CanvasSync::Importers::BulkImporter::RowBuffer

Instance Method Details

#<<(v) ⇒ Object



186
187
188
189
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 186

def <<(v)
  flush if @buffered_rows[0] && @buffered_rows[0][:canvas_user_id] != v[:canvas_user_id]
  super
end

#flushObject



191
192
193
194
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 191

def flush
  row = @buffered_rows.find{|r| r[:user_id].present? } || @buffered_rows.last
  super(row.present? ? [row] : [])
end