Sha256: 58ccec55cfb849591a72747f62e4d3d2a3cc523e66822f9f0e8603162dc72697

Contents?: true

Size: 385 Bytes

Versions: 10

Compression:

Stored size: 385 Bytes

Contents

module Jugglite
  class DeferrableBody
    include EventMachine::Deferrable

    def initialize
      @queue = EM::Queue.new
    end

    def write(body)
      @queue.push(body)
    end

    def each(&blk)
      @body_callback = blk
      processor = proc { |item|
        @body_callback.call(item)
        @queue.pop(&processor)
      }
      @queue.pop(&processor)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jugglite-1.0.0.pre lib/jugglite/deferrable_body.rb
jugglite-0.6.0 lib/jugglite/deferrable_body.rb
jugglite-0.5.0 lib/jugglite/deferrable_body.rb
jugglite-0.4.0 lib/jugglite/deferrable_body.rb
jugglite-0.3.0 lib/jugglite/deferrable_body.rb
jugglite-0.2.0 lib/jugglite/deferrable_body.rb
jugglite-0.1.0 lib/jugglite/deferrable_body.rb
jugglite-0.0.4 lib/jugglite/deferrable_body.rb
jugglite-0.0.3 lib/jugglite/deferrable_body.rb
jugglite-0.0.2.alpha lib/jugglite/deferrable_body.rb