Class: Baza::Driver::Sqlite3::UnbufferedResult
- Inherits:
-
Object
- Object
- Baza::Driver::Sqlite3::UnbufferedResult
- Defined in:
- lib/baza/driver/sqlite3/unbuffered_result.rb
Instance Method Summary collapse
- #each ⇒ Object
- #fetch ⇒ Object
-
#initialize(_driver, statement) ⇒ UnbufferedResult
constructor
A new instance of UnbufferedResult.
Constructor Details
#initialize(_driver, statement) ⇒ UnbufferedResult
Returns a new instance of UnbufferedResult.
2 3 4 5 6 |
# File 'lib/baza/driver/sqlite3/unbuffered_result.rb', line 2 def initialize(_driver, statement) @statement = statement @statement.execute @columns = statement.columns.map(&:to_sym) end |
Instance Method Details
#each ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/baza/driver/sqlite3/unbuffered_result.rb', line 21 def each loop do data = fetch if data yield data else break end end end |
#fetch ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/baza/driver/sqlite3/unbuffered_result.rb', line 8 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 |