Class: Gitlab::Diff::PositionCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gitlab/diff/position_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(collection, diff_head_sha = nil) ⇒ PositionCollection

collection - An array of Gitlab::Diff::Position


9
10
11
12
# File 'lib/gitlab/diff/position_collection.rb', line 9

def initialize(collection, diff_head_sha = nil)
  @collection = collection
  @diff_head_sha = diff_head_sha
end

Instance Method Details

#concat(positions) ⇒ Object


18
19
20
# File 'lib/gitlab/diff/position_collection.rb', line 18

def concat(positions)
  tap { @collection.concat(positions) }
end

#each(&block) ⇒ Object


14
15
16
# File 'lib/gitlab/diff/position_collection.rb', line 14

def each(&block)
  filtered_positions.each(&block)
end

#unfoldableObject

Doing a lightweight filter in-memory given we're not prepared for querying positions (gitlab.com/gitlab-org/gitlab/issues/33271).


24
25
26
27
28
# File 'lib/gitlab/diff/position_collection.rb', line 24

def unfoldable
  select do |position|
    position.unfoldable? && valid_head_sha?(position)
  end
end