From 742694e0eb1abd049aa2a4eadbc7a93591c65db4 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Fri, 26 Oct 2007 05:45:41 +0000 Subject: Simplfy #view_paths implementation. ActionView templates get the exact object, not a dup. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/base.rb | 51 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 7ca2971236..662aa09bb6 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -408,43 +408,39 @@ module ActionController #:nodoc: write_inheritable_attribute(:hidden_actions, hidden_actions | names.map(&:to_s)) end + ## View load paths determine the bases from which template references can be made. So a call to + ## render("test/template") will be looked up in the view load paths array and the closest match will be + ## returned. + def view_paths + @view_paths || superclass.view_paths + end - @@view_paths = {} - - # View load paths determine the bases from which template references can be made. So a call to - # render("test/template") will be looked up in the view load paths array and the closest match will be - # returned. def view_paths=(value) - @@view_paths[name] = value + @view_paths = value end - # View load paths for controller. - def view_paths - if paths = @@view_paths[name] - paths - else - if superclass.respond_to?(:view_paths) - superclass.view_paths.dup.freeze - else - @@view_paths[name] = [] - end - end - end - # Adds a view_path to the front of the view_paths array. # If the current class has no view paths, copy them from # the superclass + # + # ArticleController.prepend_view_path("views/default") + # ArticleController.prepend_view_path(["views/default", "views/custom"]) + # def prepend_view_path(path) - self.view_paths = view_paths.dup if view_paths.frozen? - view_paths.unshift(path) + @view_paths = superclass.view_paths.dup if @view_paths.nil? + view_paths.unshift(*path) end # Adds a view_path to the end of the view_paths array. # If the current class has no view paths, copy them from # the superclass + # + # ArticleController.append_view_path("views/default") + # ArticleController.append_view_path(["views/default", "views/custom"]) + # def append_view_path(path) - self.view_paths = view_paths.dup if view_paths.frozen? - view_paths << path + @view_paths = superclass.view_paths.dup if @view_paths.nil? + view_paths.push(*path) end # Replace sensitive paramater data from the request log. @@ -631,9 +627,16 @@ module ActionController #:nodoc: request.session_options && request.session_options[:disabled] != false end + + self.view_paths = [] + # View load paths for controller. def view_paths - self.class.view_paths + (@template || self.class).view_paths + end + + def view_paths=(value) + (@template || self.class).view_paths = value end protected -- cgit v1.2.3