123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::DescendantsTracker::WeakSet

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ObjectSpace::WeakMap
Instance Chain:
self, ObjectSpace::WeakMap
Inherits: ObjectSpace::WeakMap
Defined in: activesupport/lib/active_support/descendants_tracker.rb,
activesupport/lib/active_support/descendants_tracker.rb

Overview

On TruffleRuby ObjectSpace::WeakMap keys are strong references. So we use object_id as a key and the actual object as a value.

JRuby for now doesn't have Class#descendant, but when it will, it will likely have the same WeakMap semantic than Truffle so we future proof this as much as possible.

Class Method Summary

Instance Method Summary

Constructor Details

.newWeakSet

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 36

def initialize
  @map = ObjectSpace::WeakMap.new
end

Instance Method Details

#<<(object)

See additional method definition at line 25.

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 53

def <<(object)
  self[object] = true
end

#[](object) Also known as: #include?

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 40

def [](object)
  @map.key?(object.object_id)
end

#[]=(object, _present)

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 45

def []=(object, _present)
  @map[object.object_id] = object
end

#include?(object)

Alias for #[].

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 43

alias_method :include?, :[]

#to_a

[ GitHub ]

  
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 49

alias_method :to_a, :keys