Skip to content

Commit

Permalink
Revert "Update caching.rb"
Browse files Browse the repository at this point in the history
This reverts commit f31430a.
  • Loading branch information
cintamani committed Jan 29, 2019
1 parent 427dd05 commit 141feeb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/active_model/serializer/concerns/caching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def fetch_attributes(fields, cached_attributes, adapter_instance)
def fetch(adapter_instance, cache_options = serializer_class._cache_options, key = nil)
if serializer_class.cache_store
key ||= cache_key(adapter_instance)
cache_options = cache_options.merge(version: object_cache_version) if object_cache_version
serializer_class.cache_store.fetch(key, cache_options) do
yield
end
Expand Down Expand Up @@ -281,14 +280,12 @@ def expand_cache_key(parts)
ActiveSupport::Cache.expand_cache_key(parts)
end

def object_cache_version
object.cache_version if object.respond_to?(:cache_version)
end

# Use object's cache_key if available, else derive a key from the object
# Pass the `key` option to the `cache` declaration or override this method to customize the cache key
def object_cache_key
if object.respond_to?(:cache_key)
if object.respond_to?(:cache_key_with_version)
object.cache_key_with_version
elsif object.respond_to?(:cache_key)
object.cache_key
elsif (serializer_cache_key = (serializer_class._cache_key || serializer_class._cache_options[:key]))
object_time_safe = object.updated_at
Expand Down

0 comments on commit 141feeb

Please sign in to comment.