Class: ActiverecordHoarder::RecordCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_hoarder/record_collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ RecordCollector

Returns a new instance of RecordCollector.



4
5
6
# File 'lib/activerecord_hoarder/record_collector.rb', line 4

def initialize(model_class)
  @model_class = model_class
end

Instance Attribute Details

#relative_limitObject (readonly)

Returns the value of attribute relative_limit.



2
3
4
# File 'lib/activerecord_hoarder/record_collector.rb', line 2

def relative_limit
  @relative_limit
end

Instance Method Details

#in_batches(delete_on_success: false) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/activerecord_hoarder/record_collector.rb', line 8

def in_batches(delete_on_success: false)
  while collect_batch
    yield @batch
    next if !delete_on_success
    destroy_current_records!
  end
end