1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use Rack::BodyProxy in AD::Reloader

This commit is contained in:
Sergey Nartimov 2012-01-16 14:35:44 +03:00
parent f9f0f03822
commit 3ded9b3c26
2 changed files with 3 additions and 33 deletions

View file

@ -1,30 +0,0 @@
# Keep this file meanwhile https://github.com/rack/rack/pull/313 is not released
module ActionDispatch
class BodyProxy
def initialize(body, &block)
@body, @block, @closed = body, block, false
end
def respond_to?(*args)
super or @body.respond_to?(*args)
end
def close
return if @closed
@closed = true
begin
@body.close if @body.respond_to? :close
ensure
@block.call
end
end
def closed?
@closed
end
def method_missing(*args, &block)
@body.__send__(*args, &block)
end
end
end

View file

@ -1,5 +1,3 @@
require 'action_dispatch/middleware/body_proxy'
module ActionDispatch
# ActionDispatch::Reloader provides prepare and cleanup callbacks,
# intended to assist with code reloading during development.
@ -62,8 +60,10 @@ module ActionDispatch
def call(env)
@validated = @condition.call
prepare!
response = @app.call(env)
response[2] = ActionDispatch::BodyProxy.new(response[2]) { cleanup! }
response[2] = ::Rack::BodyProxy.new(response[2]) { cleanup! }
response
rescue Exception
cleanup!