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
- .new ⇒ WeakSet constructor
Instance Method Summary
-
#<<(object)
See additional method definition at line 23.
- #[](object) (also: #include?)
- #[]=(object, _present)
-
#include?(object)
Alias for #[].
- #to_a
Constructor Details
.new ⇒ WeakSet
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 34
def initialize @map = ObjectSpace::WeakMap.new end
Instance Method Details
#<<(object)
See additional method definition at line 23.
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 51
def <<(object) self[object] = true end
#[](object) Also known as: #include?
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 38
def [](object) @map.key?(object.object_id) end
#[]=(object, _present)
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 43
def []=(object, _present) @map[object.object_id] = object end
#include?(object)
Alias for #[].
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 41
alias_method :include?, :[]
#to_a
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 47
alias_method :to_a, :keys