Improve comments; move caching concern to caching.rb

This commit is contained in:
Benjamin Fleischer
2017-03-16 10:14:18 -05:00
parent 36b4eac79b
commit 2e71bc47f4
2 changed files with 20 additions and 15 deletions

View File

@@ -68,6 +68,18 @@ module ActiveModel
_cache_options && _cache_options[:skip_digest]
end
# @api private
# maps attribute value to explicit key name
# @see Serializer::attribute
# @see Serializer::fragmented_attributes
def _attributes_keys
_attributes_data
.each_with_object({}) do |(key, attr), hash|
next if key == attr.name
hash[attr.name] = { key: key }
end
end
def fragmented_attributes
cached = _cache_only ? _cache_only : _attributes - _cache_except
cached = cached.map! { |field| _attributes_keys.fetch(field, field) }