Method: CanvasSync.sync_scope

Defined in:
lib/canvas_sync.rb

.sync_scope(scope) ⇒ Object

Given a Model or Relation, scope it down to items that should be synced



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/canvas_sync.rb', line 102

def sync_scope(scope)
  terms = %i[should_canvas_sync active_for_canvas_sync should_sync active_for_sync active]
  terms.each do |t|
    return scope.send(t) if scope.respond_to?(t)
  end
  model = scope.try(:model) || scope
  if model.try(:column_names)&.include?(:workflow_state)
    return scope.where.not(workflow_state: %w[deleted])
  end
  Rails.logger.warn("Could not filter Syncable Scope for model '#{scope.try(:model)&.name || scope.name}'")
  scope
end