Module: CanvasSync::Concerns::Account::Ancestry

Extended by:
ActiveSupport::Concern
Includes:
Record
Defined in:
lib/canvas_sync/concerns/account/ancestry.rb

Overview

Add support for the ancestry Gem to Accounts

Requires ‘ancestry` to be added to the Gemfile and a migration to execute these steps: add_column :accounts, :ancestry, :string add_index :accounts, :ancestry

Handles syncing any Ancestry changes after CanvasSync syncs Accounts.

Instance Method Summary collapse

Methods included from Record

_get_module_parent, define_feature, registered_features

Methods included from SyncMapping

mapping_for

Instance Method Details

#ensure_ancestryObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/canvas_sync/concerns/account/ancestry.rb', line 50

def ensure_ancestry
  return unless .present?
  return if canvas_parent.present?

  self.canvas_parent = Account.find_or_fetch()
  canvas_parent.save!
  canvas_parent.ensure_ancestry
  relink_ancestry
  save! if changed?
end


46
47
48
# File 'lib/canvas_sync/concerns/account/ancestry.rb', line 46

def relink_ancestry
  self.parent = canvas_parent
end