Class: Artisan::Teams::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/artisan/teams/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, current_user) ⇒ Team

Returns a new instance of Team.



10
11
12
# File 'lib/artisan/teams/team.rb', line 10

def initialize(project, current_user)
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



8
9
10
# File 'lib/artisan/teams/team.rb', line 8

def project
  @project
end

Instance Method Details

#add_team_member(user) ⇒ Object



14
15
16
# File 'lib/artisan/teams/team.rb', line 14

def add_team_member(user)
  add_member(user, false)
end

#add_team_owner(user) ⇒ Object



18
19
20
# File 'lib/artisan/teams/team.rb', line 18

def add_team_owner(user)
  add_member(user, true)
end

#owner?(user) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/artisan/teams/team.rb', line 22

def owner?(user)
  return false if project.nil? || !user?(user)
  project_repo.is_owner?(project, user)
end

#ownersObject



38
39
40
# File 'lib/artisan/teams/team.rb', line 38

def owners
  project_repo.owners(project)
end

#remove_user(user) ⇒ Object



31
32
33
34
35
36
# File 'lib/artisan/teams/team.rb', line 31

def remove_user(user)
  project_repo.remove_member(project, user)
  if !user.nil?
    Artisan::Member.new(OpenStruct.new(:user => user, :project => project)).remove_from_email_lists
  end
end

#user?(user) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/artisan/teams/team.rb', line 27

def user?(user)
  project_repo.is_member?(project, user)
end