aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 20:29:55 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 20:29:55 +0000
commit86b86b26473e28534df23f5379a3fea5d0e8514a (patch)
treeab5323b9c19d2e2c623765da410391fbd7ac884c /actionpack/lib
parent0de0d207e83a4814a497639d226a4ff787fa871a (diff)
downloadrails-86b86b26473e28534df23f5379a3fea5d0e8514a.tar.gz
rails-86b86b26473e28534df23f5379a3fea5d0e8514a.tar.bz2
rails-86b86b26473e28534df23f5379a3fea5d0e8514a.zip
Added preliminary version of render_component
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@697 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller.rb8
-rw-r--r--actionpack/lib/action_controller/components.rb29
2 files changed, 34 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 340f41163d..d434310eff 100755
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -47,6 +47,10 @@ require 'action_controller/helpers'
require 'action_controller/cookies'
require 'action_controller/cgi_process'
require 'action_controller/caching'
+require 'action_controller/components'
+
+require 'action_view'
+ActionController::Base.template_class = ActionView::Base
ActionController::Base.class_eval do
include ActionController::Filters
@@ -60,7 +64,5 @@ ActionController::Base.class_eval do
include ActionController::Cookies
include ActionController::Session
include ActionController::Caching
+ include ActionController::Components
end
-
-require 'action_view'
-ActionController::Base.template_class = ActionView::Base \ No newline at end of file
diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb
new file mode 100644
index 0000000000..681c7b6d9a
--- /dev/null
+++ b/actionpack/lib/action_controller/components.rb
@@ -0,0 +1,29 @@
+module ActionController #:nodoc:
+ module Components #:nodoc:
+ def self.append_features(base)
+ super
+ base.helper { def render_component(options) @controller.send(:component_response, options).body end }
+ end
+
+ protected
+ def render_component(options = {}) #:doc:
+ response = component_response(options)
+ render_text(response.body, response.response_code)
+ end
+
+ private
+ def component_response(options)
+ component_class(options).process(component_request(options), @response)
+ end
+
+ def component_class(options)
+ options[:controller] ? (options[:controller].camelize + "Controller").constantize : self
+ end
+
+ def component_request(options)
+ component_request = @request.dup
+ component_request.send(:instance_variable_set, :@parameters, options[:params].merge({ "controller" => options[:controller], "action" => options[:action] }))
+ component_request
+ end
+ end
+end