Skip to content

Commit 385abb4

Browse files
committed
Simplify Serializer#cached_attributes to take a fields argument
1 parent ba23de6 commit 385abb4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/active_model/serializer/caching.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ def object_cache_key(serializer, adapter_instance)
208208
end
209209
end
210210

211-
def cached_attributes(options, cached_attributes, adapter_instance)
211+
def cached_attributes(fields, cached_attributes, adapter_instance)
212212
if self.class.cache_enabled?
213213
key = cache_key(adapter_instance)
214214
cached_attributes.fetch(key) do
215215
cache_check(adapter_instance) do
216-
attributes(options[:fields])
216+
attributes(fields)
217217
end
218218
end
219219
else
220220
cache_check(adapter_instance) do
221-
attributes(options[:fields])
221+
attributes(fields)
222222
end
223223
end
224224
end

lib/active_model_serializers/adapter/attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def serializable_hash_for_collection(options)
3333

3434
def serializable_hash_for_single_resource(options)
3535
cached_attributes = instance_options[:cached_attributes] || {}
36-
resource = serializer.cached_attributes(options, cached_attributes, self)
36+
resource = serializer.cached_attributes(options[:fields], cached_attributes, self)
3737
relationships = resource_relationships(options)
3838
resource.merge(relationships)
3939
end

0 commit comments

Comments
 (0)