Permalink
Browse files

simplify AC:ViewPaths::_prefixes. by making it recursively traversing…

… up the inheritance chain, classes can override local prefixes.
  • Loading branch information...
1 parent 2d73a73 commit 67ec435cfbb1f8d929b62dd4e76e11f7e50aa9db @apotonick apotonick committed May 8, 2014
Showing with 10 additions and 15 deletions.
  1. +10 −15 actionview/lib/action_view/view_paths.rb
@@ -14,29 +14,24 @@ module ViewPaths
:locale, :locale=, :to => :lookup_context
module ClassMethods
- def parent_prefixes
- @parent_prefixes ||= begin
- parent_controller = superclass
- prefixes = []
-
- until parent_controller.abstract?
- prefixes << parent_controller.controller_path
- parent_controller = parent_controller.superclass
- end
-
- prefixes
+ def _prefixes
+ @_prefixes ||= begin
+ return _local_prefixes if superclass.abstract?
+ _local_prefixes + superclass._prefixes
end
end
+
+ def _local_prefixes
+ [controller_path]
+ end
end
# The prefixes used in render "foo" shortcuts.
def _prefixes
- @_prefixes ||= begin
- parent_prefixes = self.class.parent_prefixes
- parent_prefixes.dup.unshift(controller_path)
- end
+ self.class._prefixes
end
+
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
# information.

0 comments on commit 67ec435

Please sign in to comment.