Fixing issue where fragment cache calls attribute methods multiple times, even when they are supposed to be cached

This commit is contained in:
Navin Peiris 2015-05-22 00:40:22 +05:30
parent 5f05944826
commit e0947fcbd4

View File

@ -35,8 +35,9 @@ module ActiveModel
private
def cached_attributes(klass, serializers)
cached_attributes = (klass._cache_only) ? klass._cache_only : serializer.attributes.keys.delete_if {|attr| klass._cache_except.include?(attr) }
non_cached_attributes = serializer.attributes.keys.delete_if {|attr| cached_attributes.include?(attr) }
attributes = serializer.class._attributes
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|
options = serializer.class._attributes_keys[attribute]
@ -75,4 +76,4 @@ module ActiveModel
end
end
end
end
end