Class: SimpleTeams::Invitation

Inherits:
ApplicationRecord show all
Defined in:
app/models/simple_teams/invitation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.expiration_windowObject



48
49
50
# File 'app/models/simple_teams/invitation.rb', line 48

def self.expiration_window
  2.weeks
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


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

def expired?
  Time.now > expires_at
end

#resend_invitation_notification(options = {}) ⇒ Object



41
42
43
44
45
46
# File 'app/models/simple_teams/invitation.rb', line 41

def resend_invitation_notification(options = {})
  if Time.now > expires_at - self.class.expiration_window + 1.day
    reset_invitation_token
  end
  send_invitation_notification(options)
end

#reset_invitation_tokenObject



35
36
37
38
39
# File 'app/models/simple_teams/invitation.rb', line 35

def reset_invitation_token
  generate_token
  set_expires_at
  self.save
end

#unexpired?Boolean

Returns:

  • (Boolean)


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

def unexpired?
  Time.now <= expires_at
end