2018-09-13 21:11:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class DiffStatsCollection
|
2018-09-19 08:26:28 -04:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
2018-09-13 21:11:35 -04:00
|
|
|
include Enumerable
|
|
|
|
|
|
|
|
def initialize(diff_stats)
|
|
|
|
@collection = diff_stats
|
|
|
|
end
|
|
|
|
|
|
|
|
def each(&block)
|
|
|
|
@collection.each(&block)
|
|
|
|
end
|
2018-09-19 08:26:28 -04:00
|
|
|
|
|
|
|
def find_by_path(path)
|
|
|
|
indexed_by_path[path]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def indexed_by_path
|
|
|
|
strong_memoize(:indexed_by_path) do
|
|
|
|
index_by { |stats| stats.path }
|
|
|
|
end
|
|
|
|
end
|
2018-09-13 21:11:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|