Class: Maquina::Invitation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Maquina::Invitation
- Defined in:
- app/models/maquina/invitation.rb
Overview
A class representing the Invitation model in the Maquina module. Manages invitations sent to users to join the system.
Attributes
email
-
The email address of the invited user (required, must be valid format).
accepted_at
-
Timestamp indicating when the invitation was accepted, nil if pending.
Validations
email
-
Must be present and in valid email format.
Instance Method Summary collapse
-
#accept! ⇒ Object
Marks the invitation as accepted with the current timestamp.
-
#accepted? ⇒ Boolean
Checks if the invitation has been accepted.
Methods inherited from ApplicationRecord
Instance Method Details
#accept! ⇒ Object
Marks the invitation as accepted with the current timestamp
Updates the accepted_at timestamp with the current time.
Returns:
-
true -> if the update was successful
-
false -> if the update failed
Raises:
-
ActiveRecord::RecordInvalid -> if validation fails
39 40 41 |
# File 'app/models/maquina/invitation.rb', line 39 def accept! update!(accepted_at: Time.zone.now) end |
#accepted? ⇒ Boolean
Checks if the invitation has been accepted
Returns:
-
true -> if the invitation has been accepted
-
false -> if the invitation is still pending
25 26 27 |
# File 'app/models/maquina/invitation.rb', line 25 def accepted? accepted_at.present? end |