Skip to content

Commit 141feeb

Browse files
committed
Revert "Update caching.rb"
This reverts commit f31430a.
1 parent 427dd05 commit 141feeb

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/active_model/serializer/concerns/caching.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ def fetch_attributes(fields, cached_attributes, adapter_instance)
231231
def fetch(adapter_instance, cache_options = serializer_class._cache_options, key = nil)
232232
if serializer_class.cache_store
233233
key ||= cache_key(adapter_instance)
234-
cache_options = cache_options.merge(version: object_cache_version) if object_cache_version
235234
serializer_class.cache_store.fetch(key, cache_options) do
236235
yield
237236
end
@@ -281,14 +280,12 @@ def expand_cache_key(parts)
281280
ActiveSupport::Cache.expand_cache_key(parts)
282281
end
283282

284-
def object_cache_version
285-
object.cache_version if object.respond_to?(:cache_version)
286-
end
287-
288283
# Use object's cache_key if available, else derive a key from the object
289284
# Pass the `key` option to the `cache` declaration or override this method to customize the cache key
290285
def object_cache_key
291-
if object.respond_to?(:cache_key)
286+
if object.respond_to?(:cache_key_with_version)
287+
object.cache_key_with_version
288+
elsif object.respond_to?(:cache_key)
292289
object.cache_key
293290
elsif (serializer_cache_key = (serializer_class._cache_key || serializer_class._cache_options[:key]))
294291
object_time_safe = object.updated_at

0 commit comments

Comments
 (0)