diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2014-01-29 15:42:07 -0500 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2014-02-05 16:53:02 -0500 |
commit | 13d2696c10726afecd393753fcac88c5a9907d8c (patch) | |
tree | 9a505cd8dc1a66b1afbf04e324fb6597c7563f20 /activerecord/lib | |
parent | d37f395be86d131d0218dadd189771f99b06874f (diff) | |
download | rails-13d2696c10726afecd393753fcac88c5a9907d8c.tar.gz rails-13d2696c10726afecd393753fcac88c5a9907d8c.tar.bz2 rails-13d2696c10726afecd393753fcac88c5a9907d8c.zip |
Return sized enumerator from Batches#find_each
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/batches.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/result.rb | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb index a06da659cb..29fc150b3d 100644 --- a/activerecord/lib/active_record/relation/batches.rb +++ b/activerecord/lib/active_record/relation/batches.rb @@ -52,7 +52,9 @@ module ActiveRecord records.each { |record| yield record } end else - enum_for :find_each, options + enum_for :find_each, options do + options[:start] ? where(table[primary_key].gteq(options[:start])).size : size + end end end diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 469451e2f4..228b2aa60f 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -54,7 +54,7 @@ module ActiveRecord if block_given? hash_rows.each { |row| yield row } else - hash_rows.to_enum + hash_rows.to_enum { @rows.size } end end |