Created
June 7, 2012 20:12
-
-
Save maxjustus/2891280 to your computer and use it in GitHub Desktop.
get child classes of a module or a class in ruby
This file contains hidden or 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.class_eval do | |
def child_classes | |
self.constants.collect do |constant| | |
c = self.const_get(constant) | |
c if c.is_a?(Class) | |
end.compact | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment