From be17361f835840c7e356dbb75a6dfcafba6d0ebf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Jul 2010 10:10:03 +0000 Subject: rev/deferred_response: cleanups Remove unnecessary include and also remove unnecessary nesting. --- lib/rainbows/rev/deferred_response.rb | 43 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/rainbows/rev/deferred_response.rb b/lib/rainbows/rev/deferred_response.rb index 243637d..f0172d6 100644 --- a/lib/rainbows/rev/deferred_response.rb +++ b/lib/rainbows/rev/deferred_response.rb @@ -1,28 +1,23 @@ # -*- encoding: binary -*- # :enddoc: -module Rainbows - module Rev +# +# this is class is specific to Rev for writing large static files +# or proxying IO-derived objects +class Rainbows::Rev::DeferredResponse < ::Rev::IO + def initialize(io, client, do_chunk, body) + super(io) + @client, @do_chunk, @body = client, do_chunk, body + end - # this is class is specific to Rev for writing large static files - # or proxying IO-derived objects - class DeferredResponse < ::Rev::IO - include Rainbows::Const - def initialize(io, client, do_chunk, body) - super(io) - @client, @do_chunk, @body = client, do_chunk, body - end + def on_read(data) + @do_chunk and @client.write("#{data.size.to_s(16)}\r\n") + @client.write(data) + @do_chunk and @client.write("\r\n") + end - def on_read(data) - @do_chunk and @client.write("#{data.size.to_s(16)}\r\n") - @client.write(data) - @do_chunk and @client.write("\r\n") - end - - def on_close - @do_chunk and @client.write("0\r\n\r\n") - @client.next - @body.respond_to?(:close) and @body.close - end - end # class DeferredResponse - end # module Rev -end # module Rainbows + def on_close + @do_chunk and @client.write("0\r\n\r\n") + @client.next + @body.respond_to?(:close) and @body.close + end +end -- cgit v1.2.3-24-ge0c7