* Clarify uncommunicative variables in labor classes Single letter variable names are largely a question of preference, in some cases I think that convention mitigates the opaque nature of single letter variable names (e.g., e for error, i for index, etc). However, in some cases they can be unclear and there isn't much reason to use single letter variables unless for some reason character length is really important. In this case, I would prefer clarity in variable names over brevity of code so I've used Reek to identify short variable names and I'm changing them. It's pretty boring, but hopefully incremental code love changes like this one add up and improve readability and accessibility for those interested in reading this codebase. * Remove commented code from 2 years ago * Clarify uncommunicative naming in services classes There is some context for this change in 6b81880f * Clarify uncommunicative naming in models There is some context for this change in 6b81880f * Clarify uncommunicative naming in liquid_tags There is some context for this change in 6b81880f
14 lines
644 B
Ruby
14 lines
644 B
Ruby
class Identity < ApplicationRecord
|
|
belongs_to :user
|
|
has_many :backup_data, as: :instance, class_name: "BackupData", dependent: :destroy
|
|
validates :uid, :provider, presence: true
|
|
validates :uid, uniqueness: { scope: :provider }, if: proc { |identity| identity.uid_changed? || identity.provider_changed? }
|
|
validates :user_id, uniqueness: { scope: :provider }, if: proc { |identity| identity.user_id_changed? || identity.provider_changed? }
|
|
validates :provider, inclusion: { in: %w[github twitter] }
|
|
|
|
serialize :auth_data_dump
|
|
|
|
def self.find_for_oauth(auth)
|
|
find_or_create_by(uid: auth.uid, provider: auth.provider)
|
|
end
|
|
end
|