diff options
author | Ignatius Reza <lyoneil.de.sire@gmail.com> | 2016-07-21 08:35:55 +0900 |
---|---|---|
committer | Ignatius Reza <lyoneil.de.sire@gmail.com> | 2016-07-21 08:42:56 +0900 |
commit | 714c763dad908d6f70df978f7bb1de950b382d67 (patch) | |
tree | 1bc639fa603601c7f90a285e3e34d0c19060654e /actionview/lib/action_view/renderer/partial_renderer | |
parent | b334c19c0746fce218faf73bbb8594915fdfcf0a (diff) | |
download | rails-714c763dad908d6f70df978f7bb1de950b382d67.tar.gz rails-714c763dad908d6f70df978f7bb1de950b382d67.tar.bz2 rails-714c763dad908d6f70df978f7bb1de950b382d67.zip |
Bring back support for callable cache_key on collection rendering
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb b/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb index f7deba94ce..1fbe209200 100644 --- a/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb +++ b/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb @@ -25,9 +25,15 @@ module ActionView end end + def callable_cache_key? + @options[:cached].respond_to?(:call) + end + def collection_by_cache_keys + seed = callable_cache_key? ? @options[:cached] : ->(i) { i } + @collection.each_with_object({}) do |item, hash| - hash[expanded_cache_key(item)] = item + hash[expanded_cache_key(seed.call(item))] = item end end |