Module: FindClosest

Included in:
Types::Ci::RunnerWebUrlEdge, Types::MergeRequests::InteractsWithMergeRequest
Defined in:
app/graphql/types/concerns/find_closest.rb

Instance Method Summary collapse

Instance Method Details

#closest_parent(types, parent) ⇒ Object

Find the closest node which has any of the given types above this node, and return the domain object


5
6
7
8
9
10
11
12
13
14
# File 'app/graphql/types/concerns/find_closest.rb', line 5

def closest_parent(types, parent)
  while parent

    if types.any? {|type| parent.object.instance_of? type}
      return parent.object.object
    else
      parent = parent.try(:parent)
    end
  end
end