Class: UnionFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/union_finder.rb

Instance Method Summary collapse

Instance Method Details

#find_union(segments, klass) ⇒ Object


2
3
4
5
6
7
8
9
10
# File 'app/finders/union_finder.rb', line 2

def find_union(segments, klass)
  if segments.length > 1
    union = Gitlab::SQL::Union.new(segments.map { |s| s.select(:id) })

    klass.where("#{klass.table_name}.id IN (#{union.to_sql})")
  else
    segments.first
  end
end