Sha256: 1166d69a59cf5161847ced1db2d4485941d3a255390e0fe97954f661b80a0161

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

if defined?(ActiveRecord::Base)
  module ActiveRecord
    module BatchesWithProgress
      def find_each_with_progress(options = {})
        Progress.start(name.tableize, count(options)) do
          find_each do |model|
            Progress.step do
              yield model
            end
          end
        end
      end

      def find_in_batches_with_progress(options = {})
        Progress.start(name.tableize, count(options)) do
          find_in_batches do |batch|
            Progress.step batch.length do
              yield batch
            end
          end
        end
      end
    end

    class Base
      extend BatchesWithProgress
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
progress-1.1.1 lib/progress/active_record.rb
progress-1.1.0 lib/progress/active_record.rb
progress-1.0.1 lib/progress/active_record.rb