aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/result.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/result.rb')
-rw-r--r--activerecord/lib/active_record/result.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index 8405fdaeb9..c84ad586e2 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -42,6 +42,10 @@ module ActiveRecord
@column_types = column_types
end
+ def length
+ @rows.length
+ end
+
def each
if block_given?
hash_rows.each { |row| yield row }
@@ -50,6 +54,15 @@ module ActiveRecord
end
end
+ def each_pair
+ return to_enum(__method__) unless block_given?
+
+ columns = @columns.map { |c| c.dup.freeze }
+ @rows.each do |row|
+ yield columns, row
+ end
+ end
+
def to_hash
hash_rows
end