Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created August 29, 2008 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atduskgreg/8055 to your computer and use it in GitHub Desktop.
Save atduskgreg/8055 to your computer and use it in GitHub Desktop.
def subclasses_of klass
result = []
ObjectSpace.each_object(Class) do |o|
result << o if o.ancestors.include? klass
end
result.reject{|i| i == klass}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment