Fix up caching, especially fragment_cache

This commit is contained in:
Benjamin Fleischer
2016-06-06 21:10:16 -05:00
parent d191342a6c
commit 35a7c81034
5 changed files with 62 additions and 75 deletions

View File

@@ -167,7 +167,7 @@ module ActiveModel
adapter_options ||= {}
options[:include_directive] ||= ActiveModel::Serializer.include_directive_from_options(adapter_options)
cached_attributes = adapter_options[:cached_attributes] ||= {}
resource = cached_attributes(options[:fields], cached_attributes, adapter_instance)
resource = fetch_attributes(options[:fields], cached_attributes, adapter_instance)
relationships = resource_relationships(adapter_options, options, adapter_instance)
resource.merge(relationships)
end
@@ -195,6 +195,8 @@ module ActiveModel
if respond_to?(attr)
send(attr)
elsif self.class._fragmented
# Attribute method wasn't available on this (fragment cached) serializer,
# so read it from the original serializer it was based on.
self.class._fragmented.read_attribute_for_serialization(attr)
else
object.read_attribute_for_serialization(attr)