Class: MrCommon::PreRegistration

Inherits:
ApplicationRecord show all
Defined in:
app/models/mr_common/pre_registration.rb

Overview

When MrCommon.enable_pre_registration is true newly created Registrations will be checked against existing PreRegistrations. If a PreRegistration is found the Registration will be confirmed automatically.

A PreRegistration requires a first+last name OR an email to be valid.

Class Method Summary collapse

Class Method Details

.exists_for?(registration) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'app/models/mr_common/pre_registration.rb', line 18

def self.exists_for?(registration)
  email = registration.email&.downcase
  name = normalized_name_from(registration).presence

  exists_for_email = email.present? ? exists?(email: email) : false
  exists_for_name = name.present? ? exists?(normalized_name: name) : false
  exists_for_email || exists_for_name
end