Class: TeamUser

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/team_user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.any?Boolean

Returns:

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



33
34
35
# File 'app/models/team_user.rb', line 33

def to_projects
  Project.where(team_id: all.select(:team_id))
end

.to_usersObject



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

#rolesObject



53
54
55
# File 'app/models/team_user.rb', line 53

def roles
  super || []
end