class ActiveSupport::DescendantsTracker::WeakSet
:nodoc:
So we can simply use WeakMap as a ‘Set`.
On MRI `ObjectSpace::WeakMap` keys are weak references.
def <<(object)
def <<(object) self[object] = true end
def <<(object)
def <<(object) self[object] = true end
def [](object)
def [](object) @map.key?(object.object_id) end
def []=(object, _present)
def []=(object, _present) @map[object.object_id] = object end
def initialize
have the same WeakMap semantic than Truffle so we future proof this as much as possible.
JRuby for now doesn't have Class#descendant, but when it will, it will likely
So we use `object_id` as a key and the actual object as a value.
On TruffleRuby `ObjectSpace::WeakMap` keys are strong references.
def initialize @map = ObjectSpace::WeakMap.new end
def to_a
def to_a @map.values end