Adds Identity#for_user for use in an EE MR

This commit is contained in:
James Edwards-Jones 2019-05-24 15:14:19 +07:00
parent 36e15a866d
commit dac520aa57
1 changed files with 1 additions and 0 deletions

View File

@ -13,6 +13,7 @@ class Identity < ApplicationRecord
before_save :ensure_normalized_extern_uid, if: :extern_uid_changed?
after_destroy :clear_user_synced_attributes, if: :user_synced_attributes_metadata_from_provider?
scope :for_user, ->(user) { where(user: user) }
scope :with_provider, ->(provider) { where(provider: provider) }
scope :with_extern_uid, ->(provider, extern_uid) do
iwhere(extern_uid: normalize_uid(provider, extern_uid)).with_provider(provider)