summaryrefslogtreecommitdiff
path: root/app/finders/union_finder.rb
blob: c3b02f7e52fa693eabcfaf3bdc9ecf63a9c44936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class UnionFinder
  def find_union(segments, klass)
    unless klass < FromUnion
      raise TypeError, "#{klass.inspect} must include the FromUnion module"
    end

    if segments.length > 1
      klass.from_union(segments)
    else
      segments.first
    end
  end
end