Created
July 29, 2008 17:46
-
-
Save NZKoz/3133 to your computer and use it in GitHub Desktop.
This file contains 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
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