Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: v3.2.5
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (29 sloc) 0.695 kB
module ActiveRecord
###
# This class encapsulates a Result returned from calling +exec_query+ on any
# database connection adapter. For example:
#
# x = ActiveRecord::Base.connection.exec_query('SELECT * FROM foo')
# x # => #<ActiveRecord::Result:0xdeadbeef>
class Result
include Enumerable
attr_reader :columns, :rows
def initialize(columns, rows)
@columns = columns
@rows = rows
@hash_rows = nil
end
def each
hash_rows.each { |row| yield row }
end
def to_hash
hash_rows
end
private
def hash_rows
@hash_rows ||= @rows.map { |row|
Hash[@columns.zip(row)]
}
end
end
end
Jump to Line
Something went wrong with that request. Please try again.