Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/progress/active_record.rb
Overview
Add find_each_with_progress and find_in_batches_with_progress method to ActiveRecord::Base
Instance Method Summary collapse
-
#find_each_with_progress(options = {}) ⇒ Object
run ‘find_each` with progress.
-
#find_in_batches_with_progress(options = {}) ⇒ Object
run ‘find_in_batches` with progress.
Instance Method Details
#find_each_with_progress(options = {}) ⇒ Object
run ‘find_each` with progress
10 11 12 13 14 15 16 17 18 |
# File 'lib/progress/active_record.rb', line 10 def find_each_with_progress( = {}) Progress.start(name.tableize, count()) do find_each do |model| Progress.step do yield model end end end end |
#find_in_batches_with_progress(options = {}) ⇒ Object
run ‘find_in_batches` with progress
21 22 23 24 25 26 27 28 29 |
# File 'lib/progress/active_record.rb', line 21 def find_in_batches_with_progress( = {}) Progress.start(name.tableize, count()) do find_in_batches do |batch| Progress.step batch.length do yield batch end end end end |