Class: SimpleProcessor::BatchProcessor
- Inherits:
-
Object
- Object
- SimpleProcessor::BatchProcessor
- Defined in:
- lib/simple_processor/batch_processor.rb
Overview
Class for processing records in batches
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BatchProcessor
constructor
A new instance of BatchProcessor.
-
#run ⇒ Object
Executes the batch processing over all stories.
Constructor Details
#initialize(opts = {}) ⇒ BatchProcessor
Returns a new instance of BatchProcessor.
23 24 25 |
# File 'lib/simple_processor/batch_processor.rb', line 23 def initialize(opts = {}) @ar_migration = opts[:ar_migration] end |
Class Method Details
.processor_handlers(*handlers_args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/simple_processor/batch_processor.rb', line 6 def self.processor_handlers(*handlers_args) define_method :handlers do @handlers ||= handlers_args.map do |handler| handlers_module.const_get(handler.to_s.camelize).new end end end |
.processor_model(klass) ⇒ Object
14 15 16 17 18 |
# File 'lib/simple_processor/batch_processor.rb', line 14 def self.processor_model(klass) define_method :model_klass do klass end end |
Instance Method Details
#run ⇒ Object
Executes the batch processing over all stories
28 29 30 31 32 33 34 |
# File 'lib/simple_processor/batch_processor.rb', line 28 def run init_counters @bar = ::ProgressBar.create(total: model_klass.count, format: '%t: |%w| [%E]') model_klass.find_in_batches { |model| process_batch(model) } show_resume end |