Class: ActiveRecord::Result
- Inherits:
-
Object
- Object
- ActiveRecord::Result
- Includes:
- Enumerable
- Defined in:
- lib/active_record/result.rb
Overview
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>
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(columns, rows) ⇒ Result
constructor
A new instance of Result.
- #to_hash ⇒ Object
Constructor Details
#initialize(columns, rows) ⇒ Result
Returns a new instance of Result.
13 14 15 16 17 |
# File 'lib/active_record/result.rb', line 13 def initialize(columns, rows) @columns = columns @rows = rows @hash_rows = nil end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
11 12 13 |
# File 'lib/active_record/result.rb', line 11 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
11 12 13 |
# File 'lib/active_record/result.rb', line 11 def rows @rows end |
Instance Method Details
#each ⇒ Object
19 20 21 |
# File 'lib/active_record/result.rb', line 19 def each hash_rows.each { |row| yield row } end |
#to_hash ⇒ Object
23 24 25 |
# File 'lib/active_record/result.rb', line 23 def to_hash hash_rows end |