Sha256: 06e140fbcac4006bf1e1aff21bb70e4ca5e28e77fea06b81d28d1163ace9d11b
Contents?: true
Size: 695 Bytes
Versions: 102
Compression:
Stored size: 695 Bytes
Contents
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
Version data entries
102 entries across 77 versions & 10 rubygems