Class: Issuable::ProcessAssignees

Inherits:
Object
  • Object
show all
Defined in:
app/services/issuable/process_assignees.rb

Instance Method Summary collapse

Constructor Details

#initialize(assignee_ids:, add_assignee_ids:, remove_assignee_ids:, existing_assignee_ids: nil, extra_assignee_ids: nil) ⇒ ProcessAssignees

Returns a new instance of ProcessAssignees.


8
9
10
11
12
13
14
# File 'app/services/issuable/process_assignees.rb', line 8

def initialize(assignee_ids:, add_assignee_ids:, remove_assignee_ids:, existing_assignee_ids: nil, extra_assignee_ids: nil)
  @assignee_ids = assignee_ids
  @add_assignee_ids = add_assignee_ids
  @remove_assignee_ids = remove_assignee_ids
  @existing_assignee_ids = existing_assignee_ids || []
  @extra_assignee_ids = extra_assignee_ids || []
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/issuable/process_assignees.rb', line 16

def execute
  updated_new_assignees = new_assignee_ids

  if add_assignee_ids.blank? && remove_assignee_ids.blank?
    updated_new_assignees = assignee_ids if assignee_ids
  else
    updated_new_assignees |= add_assignee_ids if add_assignee_ids
    updated_new_assignees -= remove_assignee_ids if remove_assignee_ids
  end

  updated_new_assignees.uniq
end