Commit ebb8e3a6 authored by Alex Kalderimis's avatar Alex Kalderimis

Pass ignoring as an optional argument to `ItemContext`

parent 20eb0ab8
...@@ -11,10 +11,11 @@ module Gitlab ...@@ -11,10 +11,11 @@ module Gitlab
attr_reader :object, :model_class, :range attr_reader :object, :model_class, :range
attr_accessor :ignoring attr_accessor :ignoring
def initialize(object, range) def initialize(object, range, ignoring: nil)
@object = object @object = object
@range = range @range = range
@model_class = object.class @model_class = object.class
@ignoring = ignoring
end end
def min_relative_position def min_relative_position
...@@ -75,9 +76,7 @@ module Gitlab ...@@ -75,9 +76,7 @@ module Gitlab
def neighbour(item) def neighbour(item)
return unless item.present? return unless item.present?
n = self.class.new(item, range) self.class.new(item, range, ignoring: ignoring)
n.ignoring = ignoring
n
end end
def scoped_items def scoped_items
...@@ -111,7 +110,7 @@ module Gitlab ...@@ -111,7 +110,7 @@ module Gitlab
.order(Gitlab::Database.nulls_last_order('relative_position', 'DESC')) .order(Gitlab::Database.nulls_last_order('relative_position', 'DESC'))
.first .first
self.class.new(sib, range) neighbour(sib)
end end
def min_sibling def min_sibling
...@@ -119,7 +118,7 @@ module Gitlab ...@@ -119,7 +118,7 @@ module Gitlab
.order(Gitlab::Database.nulls_last_order('relative_position', 'ASC')) .order(Gitlab::Database.nulls_last_order('relative_position', 'ASC'))
.first .first
self.class.new(sib, range) neighbour(sib)
end end
def shift_left def shift_left
......
...@@ -50,9 +50,7 @@ module Gitlab ...@@ -50,9 +50,7 @@ module Gitlab
def context(object, ignoring: nil) def context(object, ignoring: nil)
return unless object return unless object
c = ItemContext.new(object, range) ItemContext.new(object, range, ignoring: ignoring)
c.ignoring = ignoring
c
end end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment