Sha256: 77e3e4e3ae737516d10f6f7473c25094b3fb060fcf856ff4635062630266357f

Contents?: true

Size: 833 Bytes

Versions: 6

Compression:

Stored size: 833 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: object.rb 259 2005-02-15 08:54:54Z 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

6 entries across 6 versions & 2 rubygems

Version Path
nitro-0.11.0 lib/glue/object.rb
nitro-0.10.0 lib/glue/object.rb
nitro-0.12.0 lib/glue/object.rb
og-0.10.0 lib/glue/object.rb
og-0.11.0 lib/glue/object.rb
og-0.12.0 lib/glue/object.rb