Created
June 16, 2012 13:33
-
-
Save paradoja/2941345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_ancestor_of?(other_page) | |
other_page.is_descendant_of? self | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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