Class: Baza::Driver::Mysql2::Result
- Inherits:
-
ResultBase
- Object
- ResultBase
- Baza::Driver::Mysql2::Result
- Defined in:
- lib/baza/driver/mysql2/result.rb
Overview
This class controls the result for the MySQL2 driver.
Instance Method Summary collapse
-
#each ⇒ Object
Loops over every single result yielding it.
-
#fetch ⇒ Object
Returns a single result.
-
#initialize(driver, result) ⇒ Result
constructor
Constructor.
Methods inherited from ResultBase
Constructor Details
#initialize(driver, result) ⇒ Result
Constructor. This should not be called manually.
4 5 6 7 |
# File 'lib/baza/driver/mysql2/result.rb', line 4 def initialize(driver, result) @result = result @type_translation = driver.db.opts[:type_translation] end |
Instance Method Details
#each ⇒ Object
Loops over every single result yielding it.
17 18 19 20 21 22 23 24 25 |
# File 'lib/baza/driver/mysql2/result.rb', line 17 def each return unless @result @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 |
#fetch ⇒ Object
Returns a single result.
10 11 12 13 14 |
# File 'lib/baza/driver/mysql2/result.rb', line 10 def fetch return to_enum.next rescue StopIteration return false end |