Module: Invitations::Base

Extended by:
ActiveSupport::Concern
Included in:
Invitation
Defined in:
app/models/concerns/invitations/base.rb

Instance Method Summary collapse

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

Returns:

  • (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

#nameObject



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_emailObject



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_membershipObject



24
25
26
# File 'app/models/concerns/invitations/base.rb', line 24

def set_added_by_membership
  membership.update(added_by: from_membership)
end