Class: SafePgMigrations::Helpers::BatchOver

Inherits:
Object
  • Object
show all
Defined in:
lib/safe-pg-migrations/helpers/batch_over.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, of: SafePgMigrations.config.backfill_batch_size) ⇒ BatchOver

Returns a new instance of BatchOver.



6
7
8
9
10
11
# File 'lib/safe-pg-migrations/helpers/batch_over.rb', line 6

def initialize(model, of: SafePgMigrations.config.backfill_batch_size)
  @model = model
  @of = of

  @current_range = nil
end

Instance Method Details

#each_batchObject



13
14
15
# File 'lib/safe-pg-migrations/helpers/batch_over.rb', line 13

def each_batch
  yield scope.where(primary_key => @current_range) while next_batch
end