Sha256: f08ddaefbf9d4de1740d32f43bea26bb62944f5b38335142df9e5a5a7968fc27
Contents?: true
Size: 831 Bytes
Versions: 5
Compression:
Stored size: 831 Bytes
Contents
# * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. # $Id: object.rb 1 2005-04-11 11:04:30Z gmosx $ # Code from RubyOnRails (http://www.rubyonrails.com) class Object #:nodoc: def remove_subclasses_of(superclass) subclasses_of(superclass).each { |subclass| Object.send(:remove_const, subclass) rescue nil } end def subclasses_of(superclass) subclasses = [] ObjectSpace.each_object(Class) do |k| next if !k.ancestors.include?(superclass) || superclass == k || k.to_s.include?("::") || subclasses.include?(k.to_s) subclasses << k.to_s end subclasses end end # Code from RubyOnRails (http://www.rubyonrails.com) class Class #:nodoc: def remove_subclasses Object.remove_subclasses_of(self) end def subclasses Object.subclasses_of(self) end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
glue-0.17.0 | lib/glue/object.rb |
glue-0.16.0 | lib/glue/object.rb |
glue-0.18.0 | lib/glue/object.rb |
glue-0.18.1 | lib/glue/object.rb |
glue-0.19.0 | lib/glue/object.rb |