Skip to content

Instantly share code, notes, and snippets.

@deevis
Created August 26, 2013 21:33
Show Gist options
  • Save deevis/6346913 to your computer and use it in GitHub Desktop.
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
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