Skip to content

Instantly share code, notes, and snippets.

@paradoja
Created June 16, 2012 13:33
Show Gist options
  • Save paradoja/2941345 to your computer and use it in GitHub Desktop.
Save paradoja/2941345 to your computer and use it in GitHub Desktop.
def is_ancestor_of?(other_page)
other_page.is_descendant_of? self
end
def is_descendant_of?(other_page)
return false unless other_page and page
page == other_page or page.is_descendant_of? other_page
end
def is_descendant_of?(other_page)
return false unless other_page and page
return true if page == other_page
page.is_descendant_of? other_page
end
def is_descendant_of?(other_page)
return false unless other_page and page
if page == other_page
true
else
page.is_descendant_of? other_page
end
end
def is_descendant_of?(other_page)
parent = page
while parent
return true if parent == other_page
parent = parent.page
end
false
end
def is_descendant_of?(other_page)
return false unless other_page and page
page == other_page or page.is_descendant_of? other_page
end
def is_ancestor_of?(other_page)
other_page.is_descendant_of? self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment