aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2013-06-18 03:32:01 -0700
committerBen Woosley <ben.woosley@gmail.com>2013-06-18 15:34:18 -0700
commitd6cfbaea72e1b2852ed3206c0ffea8a572048369 (patch)
tree69ae89c3fd99c398b319bb2e438ace16d44b5eed /activerecord/lib
parent353a398bee68c5ea99d76ac7601de0a5fef6f4a5 (diff)
downloadrails-d6cfbaea72e1b2852ed3206c0ffea8a572048369.tar.gz
rails-d6cfbaea72e1b2852ed3206c0ffea8a572048369.tar.bz2
rails-d6cfbaea72e1b2852ed3206c0ffea8a572048369.zip
Change Result#each to return an Enumerator when called without a block.
As with #10992, this lets us call #with_index, etc on the results.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/result.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index bea195e9b8..6156b3a5ba 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -18,7 +18,11 @@ module ActiveRecord
end
def each
- hash_rows.each { |row| yield row }
+ if block_given?
+ hash_rows.each { |row| yield row }
+ else
+ hash_rows.to_enum
+ end
end
def to_hash