blob: 1d76e872364a7ff991355fadfea5af84aacd894e (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
# frozen_string_literal: true
module FindClosest
# Find the closest node of a given type above this node, and return the domain object
def closest_parent(type, parent)
parent = parent.try(:parent) while parent && parent.object.class != type
return unless parent
parent.object.object
end
end
|