Class: Class

Inherits:
Object show all
Defined in:
lib/backports/3.1.0/class/subclasses.rb,
lib/backports/3.2.0/class/attached_object.rb

Instance Method Summary collapse

Instance Method Details

#attached_objectObject

Raises:

  • (TypeError)


5
6
7
8
# File 'lib/backports/3.2.0/class/attached_object.rb', line 5

def attached_object
  raise TypeError, "`#{self}' is not a singleton class" unless singleton_class?
  ObjectSpace.each_object(self).first
end

#subclassesObject



5
6
7
8
9
# File 'lib/backports/3.1.0/class/subclasses.rb', line 5

def subclasses
  ObjectSpace.each_object(singleton_class).reject do |klass|
    klass.superclass != self || klass.singleton_class?
  end
end