Class: Danger::AssignStrategies::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_reviewbot/strategies/strategy.rb

Direct Known Subclasses

LeastBusyStrategy, RandomStrategy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, project:, mr:, group:) ⇒ Strategy

Returns a new instance of Strategy.



9
10
11
12
13
14
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 9

def initialize(client:, project:, mr:, group:)
  @client = client
  @project_id = project
  @mr_iid = mr
  @group_name = group
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 7

def client
  @client
end

#group_nameObject

Returns the value of attribute group_name.



6
7
8
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 6

def group_name
  @group_name
end

#mr_iidObject

Returns the value of attribute mr_iid.



4
5
6
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 4

def mr_iid
  @mr_iid
end

#project_idObject

Returns the value of attribute project_id.



5
6
7
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 5

def project_id
  @project_id
end

Instance Method Details

#assign!(amount) ⇒ Object



16
17
18
19
20
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 16

def assign!(amount)
  to_be_assigned = assignees(amount)
  response = client.assign_mr_to_users(project_id, mr_iid, to_be_assigned)
  return to_be_assigned.map(&:username)
end

#assignees(amount) ⇒ Object



22
23
24
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 22

def assignees(amount)
  raise "To be implemented in the subclasses"
end

#authorObject



26
27
28
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 26

def author
  client.fetch_author_for_mr(@project_id, @mr_iid)
end

#users_in_groupObject



30
31
32
# File 'lib/gitlab_reviewbot/strategies/strategy.rb', line 30

def users_in_group
  client.fetch_users_for_group(group_name)
end