aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/base/base.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-05-02 02:15:09 -0700
committerYehuda Katz <wycats@gmail.com>2009-05-02 02:15:09 -0700
commit72160d9f89481ea60c8268ff026099f07b1e5ed6 (patch)
tree950b7516323658c7012e3ca742b7bd9930a83aa7 /actionpack/lib/action_controller/base/base.rb
parentad2a1b5cb1afb0ea810cfdcac2ba1be95c55f1aa (diff)
downloadrails-72160d9f89481ea60c8268ff026099f07b1e5ed6.tar.gz
rails-72160d9f89481ea60c8268ff026099f07b1e5ed6.tar.bz2
rails-72160d9f89481ea60c8268ff026099f07b1e5ed6.zip
Implement FooController.action(:name)
* Rails actions are now Rack endpoints, and can be retrieved via FooController.action(name) and called with an env * Updated some tests that relied on the old internal #process/#call implementation
Diffstat (limited to 'actionpack/lib/action_controller/base/base.rb')
-rw-r--r--actionpack/lib/action_controller/base/base.rb27
1 files changed, 11 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb
index 99b5963891..243b7f8ae3 100644
--- a/actionpack/lib/action_controller/base/base.rb
+++ b/actionpack/lib/action_controller/base/base.rb
@@ -370,18 +370,18 @@ module ActionController #:nodoc:
attr_reader :template
class << self
- def call(env)
- # HACK: For global rescue to have access to the original request and response
- request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env)
- response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new
- process(request, response)
- end
-
- # Factory for the standard create, process loop where the controller is discarded after processing.
- def process(request, response) #:nodoc:
- new.process(request, response)
+ def action(name = nil)
+ @actions ||= {}
+ @actions[name] ||= proc do |env|
+ controller = new
+ # HACK: For global rescue to have access to the original request and response
+ request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env)
+ response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new
+ controller.action_name = name && name.to_s
+ controller.process(request, response).to_a
+ end
end
-
+
# Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
def controller_class_name
@controller_class_name ||= name.demodulize
@@ -518,7 +518,6 @@ module ActionController #:nodoc:
assign_shortcuts(request, response)
initialize_template_class(response)
initialize_current_url
- assign_names
log_processing
send(method, *arguments)
@@ -883,10 +882,6 @@ module ActionController #:nodoc:
@performed_render || @performed_redirect
end
- def assign_names
- @action_name = (params['action'] || 'index')
- end
-
def reset_variables_added_to_assigns
@template.instance_variable_set("@assigns_added", nil)
end