Class: RailsTransactionalOutbox::RecordProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_transactional_outbox/record_processor.rb

Defined Under Namespace

Classes: ProcessorNotFoundError

Instance Method Summary collapse

Constructor Details

#initialize(config: RailsTransactionalOutbox.configuration) ⇒ RecordProcessor

Returns a new instance of RecordProcessor.



8
9
10
# File 'lib/rails_transactional_outbox/record_processor.rb', line 8

def initialize(config: RailsTransactionalOutbox.configuration)
  @config = config
end

Instance Method Details

#call(record) ⇒ Object



12
13
14
15
16
17
# File 'lib/rails_transactional_outbox/record_processor.rb', line 12

def call(record)
  applicable_record_processors = record_processors.select { |processor| processor.applies?(record) }
  applicable_record_processors.any? or raise ProcessorNotFoundError.new(record)

  applicable_record_processors.each { |processor| processor.call(record) }
end