Skip to content
This repository
Browse code

use Rack::BodyProxy in AD::Reloader

  • Loading branch information...
commit 3ded9b3c26e7fc2684ba1200ae9263d821408545 1 parent f9f0f03
Sergey Nartimov authored January 16, 2012
30  actionpack/lib/action_dispatch/middleware/body_proxy.rb
... ...
@@ -1,30 +0,0 @@
1  
-# Keep this file meanwhile https://github.com/rack/rack/pull/313 is not released
2  
-module ActionDispatch
3  
-  class BodyProxy
4  
-    def initialize(body, &block)
5  
-      @body, @block, @closed = body, block, false
6  
-    end
7  
-
8  
-    def respond_to?(*args)
9  
-      super or @body.respond_to?(*args)
10  
-    end
11  
-
12  
-    def close
13  
-      return if @closed
14  
-      @closed = true
15  
-      begin
16  
-        @body.close if @body.respond_to? :close
17  
-      ensure
18  
-        @block.call
19  
-      end
20  
-    end
21  
-
22  
-    def closed?
23  
-      @closed
24  
-    end
25  
-
26  
-    def method_missing(*args, &block)
27  
-      @body.__send__(*args, &block)
28  
-    end
29  
-  end
30  
-end
6  actionpack/lib/action_dispatch/middleware/reloader.rb
... ...
@@ -1,5 +1,3 @@
1  
-require 'action_dispatch/middleware/body_proxy'
2  
-
3 1
 module ActionDispatch
4 2
   # ActionDispatch::Reloader provides prepare and cleanup callbacks,
5 3
   # intended to assist with code reloading during development.
@@ -62,8 +60,10 @@ def initialize(app, condition=nil)
62 60
     def call(env)
63 61
       @validated = @condition.call
64 62
       prepare!
  63
+
65 64
       response = @app.call(env)
66  
-      response[2] = ActionDispatch::BodyProxy.new(response[2]) { cleanup! }
  65
+      response[2] = ::Rack::BodyProxy.new(response[2]) { cleanup! }
  66
+
67 67
       response
68 68
     rescue Exception
69 69
       cleanup!

0 notes on commit 3ded9b3

Please sign in to comment.
Something went wrong with that request. Please try again.