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
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?
Whether the proxy is closed. The proxy starts as not closed,
def closed? @closed end
def initialize(body, &block)
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)
def method_missing(method_name, *args, &block) @body.__send__(method_name, *args, &block) end
def respond_to_missing?(method_name, include_all = false)
def respond_to_missing?(method_name, include_all = false) super or @body.respond_to?(method_name, include_all) end