Guest User

Untitled

a guest
Oct 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. def is_descendant_of?(other_page)
  2. return false unless other_page and page
  3. page == other_page or page.is_descendant_of? other_page
  4. end
  5.  
  6. def is_descendant_of?(other_page)
  7. return false unless other_page and page
  8. return true if page == other_page
  9. page.is_descendant_of? other_page
  10. end
  11.  
  12. def is_descendant_of?(other_page)
  13. return false unless other_page and page
  14. if page == other_page
  15. true
  16. else
  17. page.is_descendant_of? other_page
  18. end
  19. end
  20.  
  21. def is_descendant_of?(other_page)
  22. parent = page
  23. while parent
  24. return true if parent == other_page
  25. parent = parent.page
  26. end
  27. false
  28. end
Add Comment
Please, Sign In to add comment