Sha256: b89fef8bb4c16b2b2c5d4de21d8dd44c045e2c9067593fa14ae570bc24fc515c

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 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|
      # Seems like this happens depending on the version installed? - kaspernj
      result = result.delete_if { |k, _v| k.class.name == "Integer" || k.class.name == "Fixnum" }

      result = Hash[result.map { |k, v| [k, v.to_s] }] if @type_translation == :string

      yield result.symbolize_keys
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.38 lib/baza/driver/active_record/result.rb
baza-0.0.37 lib/baza/driver/active_record/result.rb