Skip to content

Instantly share code, notes, and snippets.

@cndaniel
Forked from ZhangHanDong/Module_subclasses.rb
Created May 27, 2017 13:23
Show Gist options
  • Save cndaniel/f123e40c4ba89b47f500fef016bdecd0 to your computer and use it in GitHub Desktop.
Save cndaniel/f123e40c4ba89b47f500fef016bdecd0 to your computer and use it in GitHub Desktop.
class Module
def subclasses
classes = []
ObjectSpace.each_object do |klass|
next unless Module === klass
classes << klass if self > klass
end
classes
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment