diff options
author | wycats <wycats@gmail.com> | 2010-12-26 23:56:09 -0800 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-12-26 23:56:09 -0800 |
commit | e03e1fdbc85bc05536a2770817c31b08d4f6be51 (patch) | |
tree | fa244a1bae2197c5b8ec7754133356a1086099b4 /actionpack/lib | |
parent | 7c568fda6ba2d6621a0872e4bc0c71bb2d13e65f (diff) | |
download | rails-e03e1fdbc85bc05536a2770817c31b08d4f6be51.tar.gz rails-e03e1fdbc85bc05536a2770817c31b08d4f6be51.tar.bz2 rails-e03e1fdbc85bc05536a2770817c31b08d4f6be51.zip |
Speed up template inheritance and remove template inheritance option
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/abstract_controller/rendering.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 01dd4ffeb1..9b912ea988 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -60,6 +60,20 @@ module AbstractController end end end + + 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 + end + end end attr_writer :view_context_class @@ -116,18 +130,10 @@ module AbstractController # The prefixes used in render "foo" shortcuts. def _prefixes - prefixes = [controller_path] - - if template_inheritance? - parent_controller = self.class.superclass - - until parent_controller.abstract? - prefixes << parent_controller.controller_path - parent_controller = parent_controller.superclass - end + @_prefixes ||= begin + parent_prefixes = self.class.parent_prefixes + parent_prefixes.dup.unshift(controller_path) end - - prefixes end private @@ -176,10 +182,5 @@ module AbstractController def _process_options(options) end - - def template_inheritance? - # is there a better way to check for config option being set? - config.template_inheritance.nil? ? true : config.template_inheritance - end end end |