Class: TeamUser
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TeamUser
- Defined in:
- app/models/team_user.rb
Class Method Summary collapse
- .any? ⇒ Boolean
- .for_user(user_or_id) ⇒ Object
- .to_projects ⇒ Object
- .to_users ⇒ Object
- .with_role(role) ⇒ Object
Instance Method Summary collapse
Class Method Details
.any? ⇒ Boolean
46 47 48 |
# File 'app/models/team_user.rb', line 46 def any? count > 0 end |
.for_user(user_or_id) ⇒ Object
41 42 43 44 |
# File 'app/models/team_user.rb', line 41 def for_user(user_or_id) user_id = user_or_id.is_a?(User) ? user_or_id.id : user_or_id where user_id: user_id end |
.to_projects ⇒ Object
33 34 35 |
# File 'app/models/team_user.rb', line 33 def to_projects Project.where(team_id: all.select(:team_id)) end |
.to_users ⇒ Object
29 30 31 |
# File 'app/models/team_user.rb', line 29 def to_users User.where(id: all.select(:user_id)) end |
.with_role(role) ⇒ Object
37 38 39 |
# File 'app/models/team_user.rb', line 37 def with_role(role) where ["? = ANY(roles)", role] end |
Instance Method Details
#roles ⇒ Object
53 54 55 |
# File 'app/models/team_user.rb', line 53 def roles super || [] end |