Sha256: e2aad67545aff2a2151f6539a7731ae61ef6c6d3cb7588afb269cc5accb5dd94

Contents?: true

Size: 1.07 KB

Versions: 28

Compression:

Stored size: 1.07 KB

Contents

# <%= autogenerated_model_warning %>

class Account < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable
  # include CanvasSync::Concerns::Account::Ancestry # Add support for the ancestry Gem

  canvas_sync_features :defaults

  validates :canvas_id, uniqueness: true, presence: true

  has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_account_id
  belongs_to :canvas_parent, class_name: 'Account', optional: true,
                             primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
  has_many :sub_accounts, class_name: 'Account',
                          primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
  has_many :groups, primary_key: :canvas_id, foreign_key: :canvas_account_id

  scope :active, -> { where.not(workflow_state: 'deleted') }
  # scope :should_canvas_sync, -> { active } # Optional - uses .active if not given

  api_syncable({
    name: :name,
    workflow_state: :workflow_state,
    canvas_parent_account_id: :parent_account_id,
  }, -> (api) { api.account(canvas_id) })
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
canvas_sync-0.20.5 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.20.4 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.20.3 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.1.beta2 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.1.beta1 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta10 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta9 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta8 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta7 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta6 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta5 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta4 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta3 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta2 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.19.0.beta1 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.18.12 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.18.10 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.18.9 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.18.8 lib/canvas_sync/generators/templates/models/account.rb