diff options
author | José Valim <jose.valim@gmail.com> | 2009-11-11 08:16:25 -0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-11-11 08:16:25 -0200 |
commit | 01ae99c681d31803f3a29f8305c9a041aa456660 (patch) | |
tree | 7fdb9e32b743aeb254854371349cecfd2499defa /actionpack/lib/action_controller/middleware.rb | |
parent | d002826e54415a340e55fdbf363d005faebf8fc5 (diff) | |
parent | fca32eb6c5b41e4f19a25b7b246c4a8a3d763667 (diff) | |
download | rails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.gz rails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.bz2 rails-01ae99c681d31803f3a29f8305c9a041aa456660.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/lib/action_controller/middleware.rb')
-rw-r--r-- | actionpack/lib/action_controller/middleware.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/middleware.rb b/actionpack/lib/action_controller/middleware.rb index fac0ed2645..17275793b7 100644 --- a/actionpack/lib/action_controller/middleware.rb +++ b/actionpack/lib/action_controller/middleware.rb @@ -1,34 +1,34 @@ module ActionController class Middleware < Metal class ActionMiddleware - def initialize(controller) - @controller = controller + def initialize(controller, app) + @controller, @app = controller, app end def call(env) - controller = @controller.allocate - controller.send(:initialize) - controller.app = @app - controller._call(env) + @controller.build(@app).dispatch(:index, env) end + end + + class << self + alias build new - def app=(app) - @app = app + def new(app) + ActionMiddleware.new(self, app) end end - - def self.new(app) - middleware = ActionMiddleware.new(self) - middleware.app = app - middleware + + attr_internal :app + + def process(action) + response = super + self.status, self.headers, self.response_body = response if response.is_a?(Array) + response end - - def _call(env) - @_env = env - @_request = ActionDispatch::Request.new(env) - @_response = ActionDispatch::Response.new - @_response.request = @_request - process(:index) + + def initialize(app) + super() + @_app = app end def index |