diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2019-01-28 14:55:12 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2019-01-28 14:55:12 -0800 |
commit | 5bb1ad59b1fea70c82d0a3b654ef81a0a31c715c (patch) | |
tree | 53a30bf40ad55ed570cb0a5066e949cd05d915f6 /actionview/lib/action_view/renderer/partial_renderer | |
parent | 793455e594dc98ea026c7665dd0de3ae8829cf73 (diff) | |
download | rails-5bb1ad59b1fea70c82d0a3b654ef81a0a31c715c.tar.gz rails-5bb1ad59b1fea70c82d0a3b654ef81a0a31c715c.tar.bz2 rails-5bb1ad59b1fea70c82d0a3b654ef81a0a31c715c.zip |
Pull `@template` in to a local variable
This gets the PartialRenderer to be a bit closer to the
TemplateRenderer. TemplateRenderer already keeps its template in a
local variable.
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer')
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb | 16 |
1 files changed, 8 insertions, 8 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 2d4a171726..b2c4fe90f4 100644 --- a/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb +++ b/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb @@ -11,13 +11,13 @@ module ActionView end private - def cache_collection_render(instrumentation_payload, view) + def cache_collection_render(instrumentation_payload, view, template) return yield unless @options[:cached] # Result is a hash with the key represents the # key used for cache lookup and the value is the item # on which the partial is being rendered - keyed_collection = collection_by_cache_keys(view) + keyed_collection = collection_by_cache_keys(view, template) # Pull all partials from cache # Result is a hash, key matches the entry in @@ -51,21 +51,21 @@ module ActionView @options[:cached].respond_to?(:call) end - def collection_by_cache_keys(view) + def collection_by_cache_keys(view, template) seed = callable_cache_key? ? @options[:cached] : ->(i) { i } @collection.each_with_object({}) do |item, hash| - hash[expanded_cache_key(seed.call(item), view)] = item + hash[expanded_cache_key(seed.call(item), view, template)] = item end end - def expanded_cache_key(key, view) - key = view.combined_fragment_cache_key(view.cache_fragment_name(key, virtual_path: @template.virtual_path, digest_path: digest_path(view))) + def expanded_cache_key(key, view, template) + key = view.combined_fragment_cache_key(view.cache_fragment_name(key, virtual_path: template.virtual_path, digest_path: digest_path(view, template))) key.frozen? ? key.dup : key # #read_multi & #write may require mutability, Dalli 2.6.0. end - def digest_path(view) - @digest_path ||= view.digest_path_from_virtual(@template.virtual_path) + def digest_path(view, template) + @digest_path ||= view.digest_path_from_virtual(template.virtual_path) end # `order_by` is an enumerable object containing keys of the cache, |