celluloid/reel — pull request #129 by Asmod4n (2014-01-05 14:50:50+00:00)
Title: Added a way to close IO Objects encoded as a Enumerable

Webmachine-Ruby Encodes IO Objects as a Enumerable.
Another possible way to handle it would be
```ruby
# Render a given response object to the network socket
def handle_response(response)
@socket << render_header(response)
return response.render(@socket) if response.respond_to?(:render)

if response.body.respond_to?(:copy_stream)
response.body.copy_stream(@socket)
else
case response.body
when String
@socket << response.body
when IO
Celluloid::IO.copy_stream(response.body, @socket)
when Enumerable
response.body.each { |chunk| write(chunk) }
# Webmachine-Ruby Encodes IO Objects as a Enumerable, so it needs to be closed here.
response.body.close if response.body.respond_to?(:close)
finish_response
when NilClass
# Used for streaming Transfer-Encoding chunked responses
return
else
raise TypeError, "don't know how to render a #{response.body.class}"
end
end
end
```
But Celluloid::IO doesn't do anything then.