Created
November 16, 2011 19:05
-
-
Save blasterpal/1371000 to your computer and use it in GitHub Desktop.
Recursion of children
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
module ContentAllChildrenMethods | |
def all_my_children | |
kids = [] | |
children.each do |child| | |
kids << child | |
kids << child.all_my_children | |
end | |
kids.flatten | |
end | |
end | |
class Content | |
include ContentAllChildrenMethods | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment