diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-15 15:57:12 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-15 15:57:12 -0700 |
commit | 7e10504bdeab14ea70a942110a1b1ef6d8467ed3 (patch) | |
tree | ee0794eff8073fc91ca5bc38cbba87b92b65a8af /actionpack/lib/action_controller/abstract/base.rb | |
parent | eb021707f53be46140b55a48e5ef03ed0577a45c (diff) | |
download | rails-7e10504bdeab14ea70a942110a1b1ef6d8467ed3.tar.gz rails-7e10504bdeab14ea70a942110a1b1ef6d8467ed3.tar.bz2 rails-7e10504bdeab14ea70a942110a1b1ef6d8467ed3.zip |
Refactored AbstractController to provide better hook points for overriding aspects of action dispatching
Diffstat (limited to 'actionpack/lib/action_controller/abstract/base.rb')
-rw-r--r-- | actionpack/lib/action_controller/abstract/base.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb index f2db201063..1f2f096dae 100644 --- a/actionpack/lib/action_controller/abstract/base.rb +++ b/actionpack/lib/action_controller/abstract/base.rb @@ -69,14 +69,13 @@ module AbstractController end def process(action_name) - action_name = action_name.to_s + @_action_name = action_name = action_name.to_s - unless respond_to_action?(action_name) + unless action_name = method_for_action(action_name) raise ActionNotFound, "The action '#{action_name}' could not be found" end - - @_action_name = action_name - process_action + + process_action(action_name) self end @@ -95,18 +94,22 @@ module AbstractController # is overridden in a subclass. For instance, ActionController::Base # overrides it to include the case where a template matching the # action_name is found. - def process_action - if action_method?(action_name) then send(action_name) - elsif respond_to?(:action_missing, true) then action_missing(action_name) - end + def process_action(method_name) + send(method_name) end - + + def _handle_action_missing + action_missing(@_action_name) + end + # Override this to change the conditions that will raise an # ActionNotFound error. If you accept a difference case, # you must handle it by also overriding process_action and # handling the case. - def respond_to_action?(action_name) - action_method?(action_name) || respond_to?(:action_missing, true) + def method_for_action(action_name) + if action_method?(action_name) then action_name + elsif respond_to?(:action_missing, true) then "_handle_action_missing" + end end end end
\ No newline at end of file |