Class: Course::UserInvitation

Inherits:
ApplicationRecord show all
Defined in:
app/models/course/user_invitation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_user(user) ⇒ Object

Finds an invitation that matches one of the user's registered emails.

Parameters:


25
26
27
# File 'app/models/course/user_invitation.rb', line 25

def self.for_user(user)
  find_by(email: user.emails.confirmed.select(:email))
end

Instance Method Details

#confirm!(confirmer:) ⇒ Object


29
30
31
32
33
# File 'app/models/course/user_invitation.rb', line 29

def confirm!(confirmer:)
  self.confirmed_at = Time.zone.now
  self.confirmer = confirmer
  save!
end

#confirmed?Boolean

Returns:

  • (Boolean)

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

def confirmed?
  confirmed_at.present?
end