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



198
199
200
201
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 198

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

#flushObject



203
204
205
206
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 203

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