Class: Gitlab::Suggestions::FileSuggestion

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/suggestions/file_suggestion.rb

Constant Summary collapse

SuggestionForDifferentFileError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, suggestions) ⇒ FileSuggestion

Returns a new instance of FileSuggestion.



14
15
16
17
18
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 14

def initialize(file_path, suggestions)
  @file_path = file_path
  @suggestions = suggestions.sort_by(&:from_line_index)
  @blob = suggestions.first&.diff_file&.new_blob
end

Instance Attribute Details

#blobObject (readonly)

Returns the value of attribute blob.



11
12
13
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 11

def blob
  @blob
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



10
11
12
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 10

def file_path
  @file_path
end

#suggestionsObject (readonly)

Returns the value of attribute suggestions.



12
13
14
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 12

def suggestions
  @suggestions
end

Instance Method Details

#line_conflict?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 20

def line_conflict?
  strong_memoize(:line_conflict) do
    _line_conflict?
  end
end

#new_contentObject



26
27
28
# File 'lib/gitlab/suggestions/file_suggestion.rb', line 26

def new_content
  @new_content ||= _new_content
end