diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-11-17 15:27:16 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-11-17 20:01:53 +0300 |
commit | 9ac0c76b78cd04b2505924f003dd720a0f155959 (patch) | |
tree | 67af1f0be0b9d6b5fc42b27c5afe5516e2c7574c /app/services/concerns/issues | |
parent | 0af35d7e30e373b885bfddb30b14718d72d75ab0 (diff) |
Use StrongMemoize and enable/disable cops properly
Diffstat (limited to 'app/services/concerns/issues')
-rw-r--r-- | app/services/concerns/issues/resolve_discussions.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/app/services/concerns/issues/resolve_discussions.rb b/app/services/concerns/issues/resolve_discussions.rb index df78ffbb6bd..fc312aad8bd 100644 --- a/app/services/concerns/issues/resolve_discussions.rb +++ b/app/services/concerns/issues/resolve_discussions.rb @@ -1,5 +1,7 @@ module Issues module ResolveDiscussions + include Gitlab::Utils::StrongMemoize + attr_reader :merge_request_to_resolve_discussions_of_iid, :discussion_to_resolve_id # rubocop:disable Cop/ModuleWithInstanceVariables @@ -7,21 +9,20 @@ module Issues @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 + # rubocop:enable Cop/ModuleWithInstanceVariables - # rubocop:disable Cop/ModuleWithInstanceVariables def merge_request_to_resolve_discussions_of - return @merge_request_to_resolve_discussions_of if defined?(@merge_request_to_resolve_discussions_of) - - @merge_request_to_resolve_discussions_of = MergeRequestsFinder.new(current_user, project_id: project.id) - .execute - .find_by(iid: merge_request_to_resolve_discussions_of_iid) + strong_memoize(:merge_request_to_resolve_discussions_of) do + MergeRequestsFinder.new(current_user, project_id: project.id) + .execute + .find_by(iid: merge_request_to_resolve_discussions_of_iid) + end end - # rubocop:disable Cop/ModuleWithInstanceVariables def discussions_to_resolve return [] unless merge_request_to_resolve_discussions_of - @discussions_to_resolve ||= + @discussions_to_resolve ||= # rubocop:disable Cop/ModuleWithInstanceVariables if discussion_to_resolve_id discussion_or_nil = merge_request_to_resolve_discussions_of .find_discussion(discussion_to_resolve_id) |