Sha256: 9557a21f07a692f43f117a006e1e064aac7b62f6cc30cb1e5937fa353ee8d2e7

Contents?: true

Size: 754 Bytes

Versions: 5

Compression:

Stored size: 754 Bytes

Contents

if defined?(ActiveRecord::Base)
  module ActiveRecord
    module BatchesWithProgress
      # run `find_each` with progress
      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

      # run `find_in_batches` with progress
      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

5 entries across 5 versions & 1 rubygems

Version Path
progress-1.2.1 lib/progress/active_record.rb
progress-1.2.0 lib/progress/active_record.rb
progress-1.1.3 lib/progress/active_record.rb
progress-1.1.2.1 lib/progress/active_record.rb
progress-1.1.2 lib/progress/active_record.rb