Class: Email

Inherits:
ApplicationRecord show all
Includes:
AsyncDeviseEmail, Gitlab::SQL::Pattern, Sortable
Defined in:
app/models/email.rb

Constant Summary

Constants included from Gitlab::SQL::Pattern

Gitlab::SQL::Pattern::MIN_CHARS_FOR_PARTIAL_MATCHING, Gitlab::SQL::Pattern::REGEX_QUOTED_WORD

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#accept_pending_invitations!Object


35
36
37
# File 'app/models/email.rb', line 35

def accept_pending_invitations!
  user.accept_pending_invitations!
end

#email=(value) ⇒ Object


27
28
29
# File 'app/models/email.rb', line 27

def email=(value)
  write_attribute(:email, value.downcase.strip)
end

#unique_emailObject


31
32
33
# File 'app/models/email.rb', line 31

def unique_email
  self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end

#update_invalid_gpg_signaturesObject

once email is confirmed, update the gpg signatures


44
45
46
# File 'app/models/email.rb', line 44

def update_invalid_gpg_signatures
  user.update_invalid_gpg_signatures if confirmed?
end

#validate_email_formatObject


39
40
41
# File 'app/models/email.rb', line 39

def validate_email_format
  self.errors.add(:email, I18n.t(:invalid, scope: 'valid_email.validations.email')) unless ValidateEmail.valid?(self.email)
end