module Memberships::Base

def role_ids=(ids)

of a team.
associated with a membership, admins can never remove the last admin
we overload this method so that when setting the list of role ids
def role_ids=(ids)
  # if this membership was an admin, and the new list of role ids don't include admin.
  if admin? && !ids.include?(Role.admin.id)
    unless team.admins.count > 1
      raise RemovingLastTeamAdminException.new("You can't remove the last team admin.")
    end
  end
  super(ids)
end