mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Fix up caching, especially fragment_cache
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user