Class: Gitlab::Diff::FileCollection::MergeRequestDiffBase

Inherits:
Base
  • Object
show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/diff/file_collection/merge_request_diff_base.rb

Direct Known Subclasses

MergeRequestDiff, MergeRequestDiffBatch

Instance Attribute Summary

Attributes inherited from Base

#diff_options, #diff_refs, #diffable, #fallback_diff_refs, #project

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods inherited from Base

default_options, #diff_file_paths, #diff_file_with_new_path, #diff_file_with_old_path, #diffs, #pagination_data, #raw_diff_files, #unfold_diff_files

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(merge_request_diff, diff_options:) ⇒ MergeRequestDiffBase

Returns a new instance of MergeRequestDiffBase.


9
10
11
12
13
14
15
16
17
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 9

def initialize(merge_request_diff, diff_options:)
  @merge_request_diff = merge_request_diff

  super(merge_request_diff,
    project: merge_request_diff.project,
    diff_options: merged_diff_options(diff_options),
    diff_refs: merge_request_diff.diff_refs,
    fallback_diff_refs: merge_request_diff.fallback_diff_refs)
end

Instance Method Details

#clear_cacheObject


36
37
38
39
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 36

def clear_cache
  highlight_cache.clear
  diff_stats_cache.clear
end

#diff_filesObject


19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 19

def diff_files
  strong_memoize(:diff_files) do
    diff_files = super

    diff_files.each { |diff_file| highlight_cache.decorate(diff_file) }

    diff_files
  end
end

#real_sizeObject


41
42
43
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 41

def real_size
  @merge_request_diff.real_size
end

#write_cacheObject


30
31
32
33
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 30

def write_cache
  highlight_cache.write_if_empty
  diff_stats_cache.write_if_empty(diff_stats_collection)
end