module BatchProcessor::Batch::Core
Public Class Methods
new(**input)
click to toggle source
Calls superclass method
# File lib/batch_processor/batch/core.rb, line 22 def initialize(**input) super(input.slice(*_attributes)) @collection_input = input.except(*_attributes) end
Public Instance Methods
collection()
click to toggle source
# File lib/batch_processor/batch/core.rb, line 27 def collection self.class::Collection.new(**collection_input) end
define_callbacks_for(*events, type)
click to toggle source
# File lib/batch_processor/batch/core.rb, line 48 def define_callbacks_for(*events, type) callbacks = events.map { |event| "#{type}_#{event}".to_sym } define_callbacks_with_handler(*callbacks) callbacks end
details()
click to toggle source
# File lib/batch_processor/batch/core.rb, line 31 def details BatchProcessor::BatchDetails.new(batch_id) end
find(batch_id)
click to toggle source
# File lib/batch_processor/batch/core.rb, line 36 def find(batch_id) class_name = BatchProcessor::BatchDetails.class_name_for_batch_id(batch_id) raise BatchProcessor::NotFoundError, "A Batch with id #{batch_id} was not found." if class_name.nil? batch_class = class_name.safe_constantize raise BatchProcessor::ClassMissingError, "#{class_name} is not a class" if batch_class.nil? batch_class.new(batch_id: batch_id) end