When caching, return the object's cache_key up front if it's defined.

This will prevent objects PORO objects that don't have updated_at defined, from throwing an error.

Not as big a deal now that PORO objects can inherit ActiveModelSerializers::Model, but still necessary if it's not inherited for whatever reason.

Add the Adapter type to the cache key.

This prevents incorrect results when the same object is serialized with different adapters.

BF:

Cherry-pick of
040a97b9e9
which was a squash of
f89ed71058

from pr 1346
This commit is contained in:
kevintyll
2015-11-25 12:31:32 -05:00
committed by Benjamin Fleischer
parent b73b780b79
commit ab6bd600e3
5 changed files with 91 additions and 28 deletions

View File

@@ -55,8 +55,8 @@ Bio = Class.new(Model)
Blog = Class.new(Model) do
FILE_DIGEST = Digest::MD5.hexdigest(File.open(__FILE__).read)
def cache_key_with_digest
"#{cache_key}/#{FILE_DIGEST}"
def digest
FILE_DIGEST
end
end
Role = Class.new(Model)