Skip to content

Instantly share code, notes, and snippets.

@NZKoz
Created July 29, 2008 17:46
Show Gist options
  • Save NZKoz/3133 to your computer and use it in GitHub Desktop.
Save NZKoz/3133 to your computer and use it in GitHub Desktop.
def subclasses_of(*superclasses) #:nodoc:
subclasses = []
superclasses.each do |sup|
ObjectSpace.each_object(class << sup; self; end) do |k|
if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id"))
subclasses << k
end
end
end
subclasses
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment