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



195
196
197
198
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 195

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

#flushObject



200
201
202
203
# File 'lib/canvas_sync/importers/bulk_importer.rb', line 200

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