Sha256: a056c43bdd42b69704bed3566c2ee2f1130879c2a9234541590fa9711844b8e7

Contents?: true

Size: 840 Bytes

Versions: 19

Compression:

Stored size: 840 Bytes

Contents

module Merb
  module Rack

    class StreamWrapper
      # :api: private
      def initialize(body)
         @body = body
      end
      
      # :api: private
      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
      
      # :api: private
      def write(str)
        @writer.call str.to_s
        str
      end
      
      # :api: private
      def to_s
        @body.to_s
      end
            
      # :api: private
      def ==(other)
        @body == other
      end

      # :api: private
      def method_missing(sym, *args, &blk)
        @body.send(sym, *args, &blk)
      end
       
    end   
  
  end
end  

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
merb-core-1.0.15 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.14 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.13 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.12 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.10 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.1 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.2 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.11 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.3 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.4 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.6.1 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.5 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.7.1 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.8.1 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.6 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.7 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.8 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0 lib/merb-core/rack/stream_wrapper.rb
merb-core-1.0.9 lib/merb-core/rack/stream_wrapper.rb