Created
August 26, 2013 21:33
-
-
Save deevis/6346913 to your computer and use it in GitHub Desktop.
Ruby - Build map of class and all subclasses as keys and with each key's locally declared instance_methods as the values
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 my_methods_and_recurse(klazz,results={}) | |
results[klazz.name] = klazz.instance_methods(false) | |
klazz.subclasses.each do |sc| | |
my_methods_and_recurse(sc, results) | |
end | |
results | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment