diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-01 17:27:44 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-01 17:31:03 -0700 |
commit | e046f36824fcc164c284a13524c6b4153010a4e1 (patch) | |
tree | 08e7420dc8cb23db244fb46bb9878ac653d6eb39 /actionpack/lib/action_controller/new_base/base.rb | |
parent | b1d34b3aa42beaf6a9fb93f114aed8fe08ebd9db (diff) | |
download | rails-e046f36824fcc164c284a13524c6b4153010a4e1.tar.gz rails-e046f36824fcc164c284a13524c6b4153010a4e1.tar.bz2 rails-e046f36824fcc164c284a13524c6b4153010a4e1.zip |
Renamed Base2 to Base and don't require old action_controller for new Base
Diffstat (limited to 'actionpack/lib/action_controller/new_base/base.rb')
-rw-r--r-- | actionpack/lib/action_controller/new_base/base.rb | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index e24c494652..8af6ffbc92 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -1,59 +1,60 @@ module ActionController - class Http < AbstractController::Base + class Base < Http abstract! - # :api: public - attr_internal :request, :response, :params - - # :api: public - def self.controller_name - @controller_name ||= controller_path.split("/").last - end + use AbstractController::Callbacks + use AbstractController::Helpers + use AbstractController::Logger - # :api: public - def controller_name() self.class.controller_name end - - # :api: public - def self.controller_path - @controller_path ||= self.name.sub(/Controller$/, '').underscore - end + use ActionController::HideActions + use ActionController::UrlFor + use ActionController::Renderer + use ActionController::Layouts + + # Legacy modules + include SessionManagement - # :api: public - def controller_path() self.class.controller_path end + # Rails 2.x compatibility + use ActionController::Rails2Compatibility - # :api: private - def self.internal_methods - ActionController::Http.public_instance_methods(true) + def self.inherited(klass) + ::ActionController::Base.subclasses << klass.to_s + super end - # :api: private - def self.action_names() action_methods end + def self.subclasses + @subclasses ||= [] + end - # :api: private - def action_names() action_methods end + def self.app_loaded! + @subclasses.each do |subclass| + subclass.constantize._write_layout_method + end + end - # :api: plugin - def self.call(env) - controller = new - controller.call(env).to_rack + def render(action = action_name, options = {}) + if action.is_a?(Hash) + options, action = action, nil + else + options.merge! :action => action + end + + super(options) end - # :api: private - def call(env) - @_request = ActionDispatch::Request.new(env) - @_response = ActionDispatch::Response.new - process(@_request.parameters[:action]) - @_response.body = response_body - @_response.prepare! - self + def render_to_body(options = {}) + options = {:template => options} if options.is_a?(String) + super end - # :api: private - def to_rack - @_response.to_a + def process_action + ret = super + render if response_body.nil? + ret + end + + def respond_to_action?(action_name) + super || view_paths.find_by_parts?(action_name.to_s, {:formats => formats, :locales => [I18n.locale]}, controller_path) end end - - class Base < Http - end -end +end
\ No newline at end of file |