Sha256: a9cd0d2bcff0e4457a5d631aa228038ec4aa4bfdfebfbf4bc9a29181425b1962

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

class Baza::Driver::ActiveRecord::Result < Baza::ResultBase
  def initialize(driver, result)
    @result = result
    @type_translation = driver.db.opts[:type_translation]
  end

  def fetch
    return to_enum.next
  rescue StopIteration
    return false
  end

  def each
    return unless @result

    @result.each do |result|
      result = result.delete_if { |k, _v| k.class.name == "Fixnum" } # Seems like this happens depending on the version installed? - kaspernj
      result = Hash[result.map { |k, v| [k, v.to_s] }] if @type_translation == :string

      yield result.symbolize_keys
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
baza-0.0.36 lib/baza/driver/active_record/result.rb
baza-0.0.35 lib/baza/driver/active_record/result.rb
baza-0.0.34 lib/baza/driver/active_record/result.rb