Sha256: 76c2a0486a960b137a6a36e985dcdd26a391f1bc6bbbb3777ec2e80c366aead8

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 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

1 entries across 1 versions & 1 rubygems

Version Path
jugglite-0.0.1.alpha lib/jugglite/deferrable_body.rb