Module: Teams::Base

Extended by:
ActiveSupport::Concern
Included in:
Team
Defined in:
app/models/concerns/teams/base.rb

Instance Method Summary collapse

Instance Method Details

#admin_usersObject



36
37
38
# File 'app/models/concerns/teams/base.rb', line 36

def admin_users
  admins.map(&:user).compact
end

#adminsObject



32
33
34
# File 'app/models/concerns/teams/base.rb', line 32

def admins
  memberships.current_and_invited.admins
end

#formatted_email_addressObject



44
45
46
# File 'app/models/concerns/teams/base.rb', line 44

def formatted_email_address
  primary_contact.email
end

#invalidate_cachesObject



48
49
50
# File 'app/models/concerns/teams/base.rb', line 48

def invalidate_caches
  users.map(&:invalidate_ability_cache)
end

#platform_agent_access_tokensObject



28
29
30
# File 'app/models/concerns/teams/base.rb', line 28

def platform_agent_access_tokens
  Platform::AccessToken.joins(:application).where(resource_owner_id: users.where.not(platform_agent_of_id: nil), application: {team: nil})
end

#primary_contactObject



40
41
42
# File 'app/models/concerns/teams/base.rb', line 40

def primary_contact
  admin_users.min { |user| user.created_at }
end

#teamObject



52
53
54
55
56
# File 'app/models/concerns/teams/base.rb', line 52

def team
  # some generic features appeal to the `team` method for security or scoping purposes, but sometimes those same
  # generic functions need to function for a team model as well, so we do this.
  self
end