aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/reloader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/reloader.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/reloader.rb23
1 files changed, 6 insertions, 17 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb
index 4f48f1c974..2f6968eb2e 100644
--- a/actionpack/lib/action_dispatch/middleware/reloader.rb
+++ b/actionpack/lib/action_dispatch/middleware/reloader.rb
@@ -18,10 +18,10 @@ module ActionDispatch
# classes before they are unloaded.
#
# By default, ActionDispatch::Reloader is included in the middleware stack
- # only in the development environment; specifically, when config.cache_classes
+ # only in the development environment; specifically, when +config.cache_classes+
# is false. Callbacks may be registered even when it is not included in the
- # middleware stack, but are executed only when +ActionDispatch::Reloader.prepare!+
- # or +ActionDispatch::Reloader.cleanup!+ are called manually.
+ # middleware stack, but are executed only when <tt>ActionDispatch::Reloader.prepare!</tt>
+ # or <tt>ActionDispatch::Reloader.cleanup!</tt> are called manually.
#
class Reloader
include ActiveSupport::Callbacks
@@ -60,8 +60,10 @@ module ActionDispatch
def call(env)
@validated = @condition.call
prepare!
+
response = @app.call(env)
- response[2].extend(module_hook)
+ response[2] = ::Rack::BodyProxy.new(response[2]) { cleanup! }
+
response
rescue Exception
cleanup!
@@ -83,18 +85,5 @@ module ActionDispatch
def validated? #:nodoc:
@validated
end
-
- def module_hook #:nodoc:
- middleware = self
- Module.new do
- define_method :close do
- begin
- super() if defined?(super)
- ensure
- middleware.cleanup!
- end
- end
- end
- end
end
end