Module: ActiveRecord::AssociatedObject::Caching

Included in:
ActiveRecord::AssociatedObject
Defined in:
lib/active_record/associated_object.rb

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



47
48
49
50
51
52
53
54
# File 'lib/active_record/associated_object.rb', line 47

def cache_key = case
when !record.cache_versioning?
  raise "ActiveRecord::AssociatedObject#cache_key only supports #{record.class}.cache_versioning = true"
when new_record?
  "#{model_name.cache_key}/new"
else
  "#{model_name.cache_key}/#{id}"
end

#cache_key_with_versionObject



42
43
44
# File 'lib/active_record/associated_object.rb', line 42

def cache_key_with_version
  "#{cache_key}-#{cache_version}".tap { _1.delete_suffix!("-") }
end