Class: CanvasSync::Jobs::SyncTermsJob

Inherits:
CanvasSync::Job show all
Defined in:
lib/canvas_sync/jobs/sync_terms_job.rb

Instance Method Summary collapse

Methods inherited from CanvasSync::Job

#create_job_log, #report_checker_wait_time, #update_or_create_model

Instance Method Details

#perform(job_chain, _options) ⇒ Object

Syncs Terms using the Canvas API

Terms are pre-synced so that provisioning reports can be scoped to term.

Parameters:

  • job_chain (Hash)
  • options (Hash)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/canvas_sync/jobs/sync_terms_job.rb', line 10

def perform(job_chain, _options)
  CanvasSync.get_canvas_sync_client(job_chain[:global_options]).terms("self").all_pages!.each do |term_params|
    if job_chain[:global_options][:account_id]
      # These branches are primarily to support Legacy apps
      if Term.respond_to?(:create_or_update) && Term.method(:create_or_update).arity.abs == 2
        Term.create_or_update(term_params, job_chain[:global_options][:account_id])
      else
        term_params[:account_id] |= job_chain[:global_options][:account_id]
        update_or_create_model(Term, term_params)
      end
    else
      update_or_create_model(Term, term_params)
    end
  end

  CanvasSync.invoke_next(job_chain)
end