aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/cache_helper.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-08-24 15:12:52 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2016-08-24 15:13:19 -0700
commit07da5aebb165f824d540fac620d2374b7a3799bb (patch)
tree562ad8d08cf75209f486472631593e4783910664 /actionview/lib/action_view/helpers/cache_helper.rb
parentef8315ac784aa778b71c803a8aa018676880b396 (diff)
downloadrails-07da5aebb165f824d540fac620d2374b7a3799bb.tar.gz
rails-07da5aebb165f824d540fac620d2374b7a3799bb.tar.bz2
rails-07da5aebb165f824d540fac620d2374b7a3799bb.zip
Simplify cache hit logging
CacheHelper is mixed in to Helpers, Helpers is mixed in to AV::Base. This means we can count on instances of AV::Base to have the "cache hit" method on them, and we can stop setting an ivar for cache logging and just ask the view if it was a cache hit.
Diffstat (limited to 'actionview/lib/action_view/helpers/cache_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index b598469d01..5258a01144 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -211,6 +211,8 @@ module ActionView
end
end
+ attr_reader :cache_hit # :nodoc:
+
private
def fragment_name_with_digest(name, virtual_path) #:nodoc:
@@ -224,13 +226,12 @@ module ActionView
end
end
- # TODO: Create an object that has caching read/write on it
def fragment_for(name = {}, options = nil, &block) #:nodoc:
if content = read_fragment_for(name, options)
- @log_payload_for_partial_render[:cache_hit] = true if defined?(@log_payload_for_partial_render)
+ @cache_hit = true
content
else
- @log_payload_for_partial_render[:cache_hit] = false if defined?(@log_payload_for_partial_render)
+ @cache_hit = false
write_fragment_for(name, options, &block)
end
end