Sha256: 6fd22f399af60517886717c102160267707fc1295c4cab3eec9df898f9d1bc6f

Contents?: true

Size: 532 Bytes

Versions: 2

Compression:

Stored size: 532 Bytes

Contents

class Baza::Driver::Sqlite3::UnbufferedResult
  def initialize(driver, statement)
    @statement = statement
    @statement.execute
    @columns = statement.columns.map { |column| column.to_sym }
  end

  def fetch
    return nil if @closed

    array = @statement.step

    if @statement.done?
      close
      return nil
    end

    return Hash[*@columns.zip(array).flatten] if array
  end

  def each
    while data = fetch
      yield data
    end
  end

private

  def close
    @statement.close
    @closed = true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.19 lib/baza/drivers/sqlite3/unbuffered_result.rb
baza-0.0.18 lib/baza/drivers/sqlite3/unbuffered_result.rb