Sha256: 4039e6387d0c8a8b2aca6c9d5a619cc70e0ffeb2efa43df922925c6dabaafd00

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

module CanvasSync
  module Jobs
    class SyncTermsJob < CanvasSync::Job
      # Syncs Terms using the Canvas API
      #
      # Terms are pre-synced so that provisioning reports can be scoped to term.
      #
      # @param job_chain [Hash]
      # @param options [Hash]
      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
canvas_sync-0.11.1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.16.5 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.16.4 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.16.3 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.16.2 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.16.1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.15.1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.15.0 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.14.0 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.13.0 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.12.0 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.11.0 lib/canvas_sync/jobs/sync_terms_job.rb