Sha256: 91ea003fc1aa8690ce317e92eae951c6387482159ce57f53701d1538db328ccf

Contents?: true

Size: 748 Bytes

Versions: 12

Compression:

Stored size: 748 Bytes

Contents

module Merb
  module Rack

    class StreamWrapper
       def initialize(body)
         @body = body
       end
            
       def each(&callback)
         if Proc === @body
           @writer = lambda { |x| callback.call(x) }
           @body.call(self)
         elsif @body.is_a?(String)
           @body.each_line(&callback)
         else
           @body.each(&callback)
         end
       end
    
       def write(str)
         @writer.call str.to_s
         str
       end
       
       def to_s
         @body.to_s
       end
       
       def ==(other)
         @body == other
       end
       
       def method_missing(sym, *args, &blk)
         @body.send(sym, *args, &blk)
       end
       
       
    end   
  
  end
end  

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.10 lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.13 lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.12 lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.11 lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.8 lib/merb-core/rack/stream_wrapper.rb
merb-core-0.9.9 lib/merb-core/rack/stream_wrapper.rb