rails/actionpack/lib/action_controller/components.rb
David Heinemeier Hansson acb3d2cf75 Fixed internal calling
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-02-20 00:02:02 +00:00

30 lines
1008 B
Ruby

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.headers["Status"])
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.class
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