diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-08 14:43:22 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-08 16:13:03 -0800 |
commit | f369b63ad69ac8bb29811e145a148dd109de777c (patch) | |
tree | 8c13982ee9f98929f532ab6865640806d9e6e5e7 /actionview/lib/action_view | |
parent | 6124eb02c63b666e640e778bf74380c3772926a0 (diff) | |
download | rails-f369b63ad69ac8bb29811e145a148dd109de777c.tar.gz rails-f369b63ad69ac8bb29811e145a148dd109de777c.tar.bz2 rails-f369b63ad69ac8bb29811e145a148dd109de777c.zip |
Teach DetailsKey how to clear the template cache
This commit exposes all system wide view paths so that we can clear
their caches.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/lookup_context.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/view_paths.rb | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 0387fd0e83..1cc0a55c31 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -78,6 +78,10 @@ module ActionView end def self.clear + ActionView::ViewPaths.all_view_paths.each do |path_set| + path_set.each(&:clear_cache) + end + ActionView::LookupContext.fallbacks.each(&:clear_cache) @view_context_class = nil @details_keys.clear @digest_cache.clear diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb index d5694d77f4..3ca5aedc14 100644 --- a/actionview/lib/action_view/view_paths.rb +++ b/actionview/lib/action_view/view_paths.rb @@ -5,13 +5,21 @@ module ActionView extend ActiveSupport::Concern included do - class_attribute :_view_paths, default: ActionView::PathSet.new.freeze + ViewPaths.set_view_paths(self, ActionView::PathSet.new.freeze) end delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=, :locale, :locale=, to: :lookup_context module ClassMethods + def _view_paths + ViewPaths.get_view_paths(self) + end + + def _view_paths=(paths) + ViewPaths.set_view_paths(self, paths) + end + def _prefixes # :nodoc: @_prefixes ||= begin return local_prefixes if superclass.abstract? @@ -29,6 +37,22 @@ module ActionView end end + # :stopdoc: + @all_view_paths = {} + + def self.get_view_paths(klass) + @all_view_paths[klass] || get_view_paths(klass.superclass) + end + + def self.set_view_paths(klass, paths) + @all_view_paths[klass] = paths + end + + def self.all_view_paths + @all_view_paths.values.uniq + end + # :startdoc: + # The prefixes used in render "foo" shortcuts. def _prefixes # :nodoc: self.class._prefixes |