From a6509d31126d3533689480a5290f518671d5d8c9 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Wed, 15 Jul 2015 23:32:45 +0200 Subject: Add wildcard template dependencies. --- actionview/lib/action_view/template/resolver.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'actionview/lib/action_view/template/resolver.rb') diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index e7208cce49..28967f40a6 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -52,6 +52,7 @@ module ActionView def initialize @data = SmallCache.new(&KEY_BLOCK) + @query_cache = SmallCache.new end # Cache the templates returned by the block @@ -70,8 +71,17 @@ module ActionView end end + def cache_query(query) # :nodoc: + if Resolver.caching? + @query_cache[query] ||= canonical_no_templates(yield) + else + yield + end + end + def clear @data.clear + @query_cache.clear end private @@ -116,6 +126,10 @@ module ActionView end end + def find_all_with_query(query) # :nodoc: + @cache.cache_query(query) { find_template_paths(File.join(@path, query)) } + end + private delegate :caching?, to: :class -- cgit v1.2.3