class Rack::BodyProxy

sent to the client).
the response body is closed (after the response has been fully
Proxy for response bodies allowing calling a block when

def close

then call the block the proxy was initialized with.
If not already closed, close the wrapped body and
def close
  return if @closed
  @closed = true
  begin
    @body.close if @body.respond_to?(:close)
  ensure
    @block.call
  end
end

def closed?

and becomes closed on the first call to close.
Whether the proxy is closed. The proxy starts as not closed,
def closed?
  @closed
end

def initialize(body, &block)

response has been fully sent.
Set the response body to wrap, and the block to call when the
def initialize(body, &block)
  @body = body
  @block = block
  @closed = false
end

def method_missing(method_name, *args, &block)

Delegate missing methods to the wrapped body.
def method_missing(method_name, *args, &block)
  @body.__send__(method_name, *args, &block)
end

def respond_to_missing?(method_name, include_all = false)

Return whether the wrapped body responds to the method.
def respond_to_missing?(method_name, include_all = false)
  super or @body.respond_to?(method_name, include_all)
end