aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/new_base.rb17
-rw-r--r--actionpack/lib/action_controller/new_base/base.rb87
-rw-r--r--actionpack/lib/action_controller/new_base/compatibility.rb21
-rw-r--r--actionpack/lib/action_controller/new_base/http.rb56
-rw-r--r--actionpack/lib/action_dispatch/middleware/stack.rb2
5 files changed, 136 insertions, 47 deletions
diff --git a/actionpack/lib/action_controller/new_base.rb b/actionpack/lib/action_controller/new_base.rb
index 47621f0847..b292fd579d 100644
--- a/actionpack/lib/action_controller/new_base.rb
+++ b/actionpack/lib/action_controller/new_base.rb
@@ -1,9 +1,22 @@
module ActionController
+ autoload :Base, "action_controller/new_base/base"
autoload :HideActions, "action_controller/new_base/hide_actions"
- autoload :Http, "action_controller/new_base/base"
+ autoload :Http, "action_controller/new_base/http"
autoload :Layouts, "action_controller/new_base/layouts"
autoload :Rails2Compatibility, "action_controller/new_base/compatibility"
autoload :Renderer, "action_controller/new_base/renderer"
autoload :Testing, "action_controller/new_base/testing"
autoload :UrlFor, "action_controller/new_base/url_for"
-end \ No newline at end of file
+
+ # Ported modules
+ # require 'action_controller/routing'
+ autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
+ autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
+ autoload :Resources, 'action_controller/routing/resources'
+ autoload :SessionManagement, 'action_controller/base/session_management'
+
+ require 'action_controller/routing'
+end
+
+require 'action_dispatch'
+require 'action_view' \ No newline at end of file
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
diff --git a/actionpack/lib/action_controller/new_base/compatibility.rb b/actionpack/lib/action_controller/new_base/compatibility.rb
index 275a18abfd..db471f7658 100644
--- a/actionpack/lib/action_controller/new_base/compatibility.rb
+++ b/actionpack/lib/action_controller/new_base/compatibility.rb
@@ -1,6 +1,27 @@
module ActionController
module Rails2Compatibility
+ # Temporary hax
+ setup do
+ cattr_accessor :session_options
+ self.send(:class_variable_set, "@@session_options", {})
+
+ cattr_accessor :allow_concurrency
+ self.send(:class_variable_set, "@@allow_concurrency", false)
+
+ cattr_accessor :param_parsers
+ self.send(:class_variable_set, "@@param_parsers", { Mime::MULTIPART_FORM => :multipart_form,
+ Mime::URL_ENCODED_FORM => :url_encoded_form,
+ Mime::XML => :xml_simple,
+ Mime::JSON => :json })
+
+ cattr_accessor :relative_url_root
+ self.send(:class_variable_set, "@@relative_url_root", ENV['RAILS_RELATIVE_URL_ROOT'])
+
+ cattr_accessor :default_charset
+ self.send(:class_variable_set, "@@default_charset", "utf-8")
+ end
+
def render_to_body(options)
if options.is_a?(Hash) && options.key?(:template)
options[:template].sub!(/^\//, '')
diff --git a/actionpack/lib/action_controller/new_base/http.rb b/actionpack/lib/action_controller/new_base/http.rb
new file mode 100644
index 0000000000..f663900944
--- /dev/null
+++ b/actionpack/lib/action_controller/new_base/http.rb
@@ -0,0 +1,56 @@
+module ActionController
+ class Http < AbstractController::Base
+ abstract!
+
+ # :api: public
+ attr_internal :request, :response, :params
+
+ # :api: public
+ def self.controller_name
+ @controller_name ||= controller_path.split("/").last
+ end
+
+ # :api: public
+ def controller_name() self.class.controller_name end
+
+ # :api: public
+ def self.controller_path
+ @controller_path ||= self.name.sub(/Controller$/, '').underscore
+ end
+
+ # :api: public
+ def controller_path() self.class.controller_path end
+
+ # :api: private
+ def self.internal_methods
+ ActionController::Http.public_instance_methods(true)
+ end
+
+ # :api: private
+ def self.action_names() action_methods end
+
+ # :api: private
+ def action_names() action_methods end
+
+ # :api: plugin
+ def self.call(env)
+ controller = new
+ controller.call(env).to_rack
+ 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
+ end
+
+ # :api: private
+ def to_rack
+ @_response.to_a
+ end
+ end
+end
diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb
index ee5f28d5cb..52abd69a42 100644
--- a/actionpack/lib/action_dispatch/middleware/stack.rb
+++ b/actionpack/lib/action_dispatch/middleware/stack.rb
@@ -34,8 +34,6 @@ module ActionDispatch
else
@klass.to_s.constantize
end
- rescue NameError
- @klass
end
def active?