Class: OutOfContextDiscussion

Inherits:
Discussion show all
Defined in:
app/models/out_of_context_discussion.rb

Overview

When notes on a commit are displayed in the context of a merge request that contains that commit, they are displayed as if they were a discussion.

This represents one of those discussions, consisting of `Note` notes.

A discussion of this type is never resolvable.

Constant Summary

Constants inherited from Discussion

Discussion::CACHE_VERSION

Instance Attribute Summary

Attributes inherited from Discussion

#context_noteable, #notes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Discussion

#==, base_discussion_id, build, build_collection, build_discussions, #cache_key, #can_convert_to_discussion?, #collapsed?, #declarative_policy_delegate, #diff_discussion?, discussion_id, #expanded?, #id, #individual_note?, #initialize, #last_note, #last_updated_at, #last_updated_by, lazy_find, #on_image?, #project_id, #reply_id, #updated?

Methods included from ResolvableDiscussion

#can_resolve?, #clear_memoized_values, #first_note, #first_note_to_resolve, #last_resolved_note, #resolvable?, #resolve!, #resolved?, #resolved_by_push?, #resolved_notes, #to_be_resolved?, #unresolve!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

This class inherits a constructor from Discussion

Class Method Details

.build_discussion_id(note) ⇒ Object

Returns an array of discussion ID components


11
12
13
# File 'app/models/out_of_context_discussion.rb', line 11

def self.build_discussion_id(note)
  base_discussion_id(note)
end

.note_classObject


21
22
23
# File 'app/models/out_of_context_discussion.rb', line 21

def self.note_class
  Note
end

.override_discussion_id(note) ⇒ Object

To make sure all out-of-context notes end up grouped as one discussion, we override the discussion ID to be a newly generated but consistent ID.


17
18
19
# File 'app/models/out_of_context_discussion.rb', line 17

def self.override_discussion_id(note)
  discussion_id(note)
end

Instance Method Details

#reply_attributesObject


25
26
27
# File 'app/models/out_of_context_discussion.rb', line 25

def reply_attributes
  super.tap { |attrs| attrs.delete(:discussion_id) }
end