mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Fixing issue where fragment cache calls attribute methods multiple times, even when they are supposed to be cached
This commit is contained in:
parent
5f05944826
commit
e0947fcbd4
@ -35,8 +35,9 @@ module ActiveModel
|
|||||||
private
|
private
|
||||||
|
|
||||||
def cached_attributes(klass, serializers)
|
def cached_attributes(klass, serializers)
|
||||||
cached_attributes = (klass._cache_only) ? klass._cache_only : serializer.attributes.keys.delete_if {|attr| klass._cache_except.include?(attr) }
|
attributes = serializer.class._attributes
|
||||||
non_cached_attributes = serializer.attributes.keys.delete_if {|attr| cached_attributes.include?(attr) }
|
cached_attributes = (klass._cache_only) ? klass._cache_only : attributes.reject {|attr| klass._cache_except.include?(attr) }
|
||||||
|
non_cached_attributes = attributes - cached_attributes
|
||||||
|
|
||||||
cached_attributes.each do |attribute|
|
cached_attributes.each do |attribute|
|
||||||
options = serializer.class._attributes_keys[attribute]
|
options = serializer.class._attributes_keys[attribute]
|
||||||
@ -75,4 +76,4 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user