Class: RailsTransactionalOutbox::RecordProcessors::ActiveRecordProcessor

Inherits:
BaseProcessor
  • Object
show all
Defined in:
lib/rails_transactional_outbox/record_processors/active_record_processor.rb

Defined Under Namespace

Classes: CouldNotFindModelError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.contextObject



9
10
11
# File 'lib/rails_transactional_outbox/record_processors/active_record_processor.rb', line 9

def self.context
  ACTIVE_RECORD_CONTEXT
end

Instance Method Details

#applies?(record) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rails_transactional_outbox/record_processors/active_record_processor.rb', line 13

def applies?(record)
  record.context == ACTIVE_RECORD_CONTEXT
end

#call(record) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails_transactional_outbox/record_processors/active_record_processor.rb', line 17

def call(record)
  model = record.infer_model
  if model.nil?
    raise CouldNotFindModelError.new(record) if RailsTransactionalOutbox.configuration.raise_not_found_model_error?

    return
  end
  model.previous_changes = record.transformed_changeset.with_indifferent_access
  model.reliable_after_commit_callbacks.for_event_type(record.event_type).each do |callback|
    callback.call(model)
  end
end