Sha256: 2eea6c186893ec0d20062e524e8d07469ae34b5f65c59a85fde0713b1d9c3747
Contents?: true
Size: 726 Bytes
Versions: 2
Compression:
Stored size: 726 Bytes
Contents
# This class controls the result for the MySQL2 driver. class Baza::Driver::Mysql2::Result < Baza::ResultBase # Constructor. This should not be called manually. def initialize(driver, result) @result = result @type_translation = driver.baza.opts[:type_translation] end # Returns a single result. def fetch begin return to_enum.next rescue StopIteration return false end end # Loops over every single result yielding it. def each @result.each(as: :hash, symbolize_keys: true) do |row| next unless row # This sometimes happens when streaming results... row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string yield row end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
baza-0.0.19 | lib/baza/drivers/mysql2/result.rb |
baza-0.0.18 | lib/baza/drivers/mysql2/result.rb |