Module: Teams::Base
Instance Method Summary collapse
- #admin_users ⇒ Object
- #admins ⇒ Object
- #formatted_email_address ⇒ Object
- #initialize(attributes = nil) ⇒ Object
- #invalidate_caches ⇒ Object
- #platform_agent_access_tokens ⇒ Object
- #primary_contact ⇒ Object
- #set_time_zone_from_user(user) ⇒ Object
- #team ⇒ Object
Instance Method Details
#admin_users ⇒ Object
48 49 50 |
# File 'app/models/concerns/teams/base.rb', line 48 def admin_users admins.map(&:user).compact end |
#admins ⇒ Object
44 45 46 |
# File 'app/models/concerns/teams/base.rb', line 44 def admins memberships.current_and_invited.admins end |
#formatted_email_address ⇒ Object
56 57 58 |
# File 'app/models/concerns/teams/base.rb', line 56 def formatted_email_address primary_contact.email end |
#initialize(attributes = nil) ⇒ Object
28 29 30 31 |
# File 'app/models/concerns/teams/base.rb', line 28 def initialize(attributes = nil) super self.time_zone = "UTC" if time_zone.blank? end |
#invalidate_caches ⇒ Object
60 61 62 |
# File 'app/models/concerns/teams/base.rb', line 60 def invalidate_caches users.map(&:invalidate_ability_cache) end |
#platform_agent_access_tokens ⇒ Object
40 41 42 |
# File 'app/models/concerns/teams/base.rb', line 40 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_contact ⇒ Object
52 53 54 |
# File 'app/models/concerns/teams/base.rb', line 52 def primary_contact admin_users.min { |user| user.created_at } end |
#set_time_zone_from_user(user) ⇒ Object
33 34 35 36 37 38 |
# File 'app/models/concerns/teams/base.rb', line 33 def set_time_zone_from_user(user) if time_zone.blank? || time_zone == "UTC" self.time_zone = user.time_zone if user.time_zone.present? save end end |
#team ⇒ Object
64 65 66 67 68 |
# File 'app/models/concerns/teams/base.rb', line 64 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 |