Sha256: edb1c3886a386169c7026b2db96421075e2dca08ccf3a61b6fd9136d1355f7b3

Contents?: true

Size: 383 Bytes

Versions: 2

Compression:

Stored size: 383 Bytes

Contents

class Baza::Driver::Tiny::Result < Baza::ResultBase
  def initialize(result)
    @result = result.to_a
    result.cancel
  end

  def each(&blk)
    enum.each(&blk)
  end

  def fetch
    enum.next
  rescue StopIteration
    nil
  end

private

  def enum
    @enum ||= Enumerator.new do |yielder|
      @result.each do |result|
        yielder << result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.38 lib/baza/driver/tiny/result.rb
baza-0.0.37 lib/baza/driver/tiny/result.rb