Module: Issues::ResolveDiscussions

Includes:
Gitlab::Utils::StrongMemoize
Included in:
BuildService, CreateService
Defined in:
app/services/concerns/issues/resolve_discussions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Attribute Details

#discussion_to_resolve_idObject (readonly)

Returns the value of attribute discussion_to_resolve_id


7
8
9
# File 'app/services/concerns/issues/resolve_discussions.rb', line 7

def discussion_to_resolve_id
  @discussion_to_resolve_id
end

#merge_request_to_resolve_discussions_of_iidObject (readonly)

Returns the value of attribute merge_request_to_resolve_discussions_of_iid


7
8
9
# File 'app/services/concerns/issues/resolve_discussions.rb', line 7

def merge_request_to_resolve_discussions_of_iid
  @merge_request_to_resolve_discussions_of_iid
end

Instance Method Details

#discussions_to_resolveObject

rubocop: enable CodeReuse/ActiveRecord


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/concerns/issues/resolve_discussions.rb', line 25

def discussions_to_resolve
  return [] unless merge_request_to_resolve_discussions_of

  @discussions_to_resolve ||= # rubocop:disable Gitlab/ModuleWithInstanceVariables
    if discussion_to_resolve_id
      discussion_or_nil = merge_request_to_resolve_discussions_of
                            .find_discussion(discussion_to_resolve_id)
      Array(discussion_or_nil)
    else
      merge_request_to_resolve_discussions_of
        .discussions_to_be_resolved
    end
end

#filter_resolve_discussion_paramsObject

rubocop:disable Gitlab/ModuleWithInstanceVariables


10
11
12
13
# File 'app/services/concerns/issues/resolve_discussions.rb', line 10

def filter_resolve_discussion_params
  @merge_request_to_resolve_discussions_of_iid ||= params.delete(:merge_request_to_resolve_discussions_of)
  @discussion_to_resolve_id ||= params.delete(:discussion_to_resolve)
end

#merge_request_to_resolve_discussions_ofObject

rubocop: disable CodeReuse/ActiveRecord


17
18
19
20
21
22
# File 'app/services/concerns/issues/resolve_discussions.rb', line 17

def merge_request_to_resolve_discussions_of
  strong_memoize(:merge_request_to_resolve_discussions_of) do
    MergeRequestsFinder.new(current_user, project_id: project.id)
      .find_by(iid: merge_request_to_resolve_discussions_of_iid)
  end
end