Sha256: a9f60d96ba133c07f1dcb9d6c03b7759080a5523b0b03c1034f34234c191631d

Contents?: true

Size: 431 Bytes

Versions: 13

Compression:

Stored size: 431 Bytes

Contents

# copied from http://snippets.dzone.com/posts/show/2992
class Object
  def self.subclasses(direct = false)
    classes = []
    if direct
      ObjectSpace.each_object(Class) do |c|
        next unless c.superclass == self
        classes << c
      end
    else
      ObjectSpace.each_object(Class) do |c|
        next unless c.ancestors.include?(self) and (c != self)
        classes << c
      end
    end
    classes
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
clevic-0.14.6 lib/clevic/subclasses.rb
clevic-0.14.5 lib/clevic/subclasses.rb
clevic-0.14.4 lib/clevic/subclasses.rb
clevic-0.14.3 lib/clevic/subclasses.rb
clevic-0.14.2 lib/clevic/subclasses.rb
clevic-0.14.1 lib/clevic/subclasses.rb
clevic-0.14.0 lib/clevic/subclasses.rb
clevic-0.13.0.b12 lib/clevic/subclasses.rb
clevic-0.13.0.b11 lib/clevic/subclasses.rb
clevic-0.13.0.b10 lib/clevic/subclasses.rb
clevic-0.13.0.b9 lib/clevic/subclasses.rb
clevic-0.13.0.b6 lib/clevic/subclasses.rb
clevic-0.13.0.b5 lib/clevic/subclasses.rb