Module: Invitations::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- Invitation
- Defined in:
- app/models/concerns/invitations/base.rb
Instance Method Summary collapse
- #accept_for(user) ⇒ Object
- #is_for?(user) ⇒ Boolean
- #name ⇒ Object
- #send_invitation_email ⇒ Object
- #set_added_by_membership ⇒ Object
Instance Method Details
#accept_for(user) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/models/concerns/invitations/base.rb', line 32 def accept_for(user) User.transaction do user.memberships << membership user.update(current_team: team, former_user: false) destroy end end |
#is_for?(user) ⇒ Boolean
44 45 46 |
# File 'app/models/concerns/invitations/base.rb', line 44 def is_for?(user) user.email.downcase.strip == email.downcase.strip end |
#name ⇒ Object
40 41 42 |
# File 'app/models/concerns/invitations/base.rb', line 40 def name I18n.t("invitations.values.name", team_name: team.name) end |
#send_invitation_email ⇒ Object
28 29 30 |
# File 'app/models/concerns/invitations/base.rb', line 28 def send_invitation_email UserMailer.invited(uuid).deliver_later end |
#set_added_by_membership ⇒ Object
24 25 26 |
# File 'app/models/concerns/invitations/base.rb', line 24 def set_added_by_membership membership.update(added_by: from_membership) end |