aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-07-05 01:30:49 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-07-05 01:30:49 +0000
commitd2b9e39c8562dba58d0d76646866a1949eb3f9a6 (patch)
tree106d3597b75382ee0503ec8aaa42454ffd0d35ca
parentc6f819edb7844bb518c23b3190b2134b23c2e43c (diff)
downloadrails-d2b9e39c8562dba58d0d76646866a1949eb3f9a6.tar.gz
rails-d2b9e39c8562dba58d0d76646866a1949eb3f9a6.tar.bz2
rails-d2b9e39c8562dba58d0d76646866a1949eb3f9a6.zip
r2828@asus: jeremy | 2005-07-04 22:02:44 -0700
cache controller_name and controller_path git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1689 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-xactionpack/lib/action_controller/base.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 15430839e7..a8c2f206b9 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -286,20 +286,24 @@ module ActionController #:nodoc:
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
def controller_class_name
- Inflector.demodulize(name)
+ @controller_class_name ||= name.demodulize
end
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "neat".
def controller_name
- Inflector.underscore(controller_class_name.sub(/Controller/, ""))
+ @controller_name ||= controller_class_name.sub(/Controller$/, '').underscore
end
# Convert the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat".
def controller_path
- components = self.name.to_s.split('::').collect { |name| name.underscore }
- components[-1] = $1 if /^(.*)_controller$/ =~ components[-1]
- components.shift if components.first == 'controllers' # Transitional conditional to accomodate root Controllers module
- components.join('/')
+ unless @controller_path
+ components = self.name.to_s.split('::')
+ components[-1] = $1 if /^(.*)Controller$/ =~ components.last
+ # Accomodate the root Controllers module.
+ components.shift if components.first == 'Controllers'
+ @controller_path = components.map { |name| name.underscore }.join('/')
+ end
+ @controller_path
end
# Return an array containing the names of public methods that have been marked hidden from the action processor.