Skip to content

Instantly share code, notes, and snippets.

@maxjustus
Created June 7, 2012 20:12
Show Gist options
  • Save maxjustus/2891280 to your computer and use it in GitHub Desktop.
Save maxjustus/2891280 to your computer and use it in GitHub Desktop.
get child classes of a module or a class in ruby
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