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
Instance Method Details
#ensure_ancestry ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/canvas_sync/concerns/account/ancestry.rb', line 48 def ensure_ancestry return unless canvas_parent_account_id.present? return if canvas_parent.present? self.canvas_parent = Account.find_or_fetch(canvas_parent_account_id) canvas_parent.save! canvas_parent.ensure_ancestry relink_ancestry save! if changed? end |
#relink_ancestry ⇒ Object
44 45 46 |
# File 'lib/canvas_sync/concerns/account/ancestry.rb', line 44 def relink_ancestry self.parent = canvas_parent end |