mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Remove unnecessary Serializer#cached_fields
This commit is contained in:
parent
eb86663393
commit
96750b2f9a
@ -206,15 +206,6 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
# Get attributes from @cached_attributes
|
||||
# @return [Hash] cached attributes
|
||||
# def cached_attributes(fields, adapter_instance)
|
||||
def cached_fields(fields, adapter_instance)
|
||||
cache_check(adapter_instance) do
|
||||
attributes(fields)
|
||||
end
|
||||
end
|
||||
|
||||
def cache_check(adapter_instance)
|
||||
if self.class.cache_enabled?
|
||||
self.class.cache_store.fetch(cache_key(adapter_instance), self.class._cache_options) do
|
||||
|
||||
@ -37,10 +37,14 @@ module ActiveModelSerializers
|
||||
cached_attributes = instance_options[:cached_attributes] || {}
|
||||
key = serializer.cache_key(self)
|
||||
cached_attributes.fetch(key) do
|
||||
serializer.cached_fields(options[:fields], self)
|
||||
serializer.cache_check(self) do
|
||||
serializer.attributes(options[:fields])
|
||||
end
|
||||
end
|
||||
else
|
||||
serializer.cached_fields(options[:fields], self)
|
||||
serializer.cache_check(self) do
|
||||
serializer.attributes(options[:fields])
|
||||
end
|
||||
end
|
||||
relationships = resource_relationships(options)
|
||||
resource.merge(relationships)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user