123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::AssociationRoute::Cache

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::ActiveSupport::WeakKeyMap, ObjectSpace::WeakKeyMap
Instance Chain:
self, ::ActiveSupport::WeakKeyMap, ObjectSpace::WeakKeyMap
Inherits: ActiveSupport::WeakKeyMap
Defined in: activerecord/lib/active_record/association_route.rb

Constant Summary

Class Method Summary

Instance Method Summary

::ActiveSupport::WeakKeyMap - Inherited

#[], #[]=, #clear, #delete,
#fetch_or_store

Returns the cached value, computing and storing it when nil.

Constructor Details

This class inherits a constructor from ActiveSupport::WeakKeyMap

Class Method Details

.clear(key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/association_route.rb', line 185

def self.clear(key)
  ActiveSupport::Ractors[:active_record_association_route_caches]&.delete(key)
end

.for(key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/association_route.rb', line 180

def self.for(key)
  registry = ActiveSupport::Ractors.store_if_absent(:active_record_association_route_caches) { new }
  registry.fetch_or_store(key) { new }
end

Instance Method Details

#fetch_or_store(key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/association_route.rb', line 189

def fetch_or_store(key)
  super(key.nil? ? NIL_KEY : key)
end