diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-15 22:47:44 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-20 16:54:32 +0100 |
commit | b4558c10fb8f5379ffe23860c9ad1ee7a227de44 (patch) | |
tree | e970d2796ba27d9d6d5ef7bf4a747103f69104d6 /actionview/lib/action_view/template.rb | |
parent | 454bc1deab3b60f6b4cbe36227471ed40f4c38f9 (diff) | |
download | rails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.tar.gz rails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.tar.bz2 rails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.zip |
Make collection caching explicit.
Having collection caching that wraps templates and automatically tries
to infer if they are cachable proved to be too much of a hassle.
We'd rather have it be something you explicitly turn on.
This removes much of the code and docs to explain the previous automatic
behavior.
This change also removes scoped cache keys and passing cache_options.
Diffstat (limited to 'actionview/lib/action_view/template.rb')
-rw-r--r-- | actionview/lib/action_view/template.rb | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 15fc2b71a3..169ee55fdc 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -130,7 +130,6 @@ module ActionView @source = source @identifier = identifier @handler = handler - @cache_name = extract_resource_cache_name @compiled = false @original_encoding = nil @locals = details[:locals] || [] @@ -166,10 +165,6 @@ module ActionView @type ||= Types[@formats.first] if @formats.first end - def eligible_for_collection_caching?(as: nil) - @cache_name == (as || inferred_cache_name).to_s - end - # Receives a view object and return a template similar to self by using @virtual_path. # # This method is useful if you have a template object but it does not contain its source @@ -355,23 +350,5 @@ module ActionView ActiveSupport::Notifications.instrument("#{action}.action_view".freeze, payload, &block) end end - - EXPLICIT_COLLECTION = /# Template Collection: (?<resource_name>\w+)/ - - def extract_resource_cache_name - if match = @source.match(EXPLICIT_COLLECTION) || resource_cache_call_match - match[:resource_name] - end - end - - def resource_cache_call_match - if @handler.respond_to?(:resource_cache_call_pattern) - @source.match(@handler.resource_cache_call_pattern) - end - end - - def inferred_cache_name - @inferred_cache_name ||= @virtual_path.split('/'.freeze).last.sub('_'.freeze, ''.freeze) - end end end |