Sha256: 75e46520c1da34a36cad129287ff7370fc06a6616071dc1baa3ed71fdd64b889
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true class RailsTransactionalOutbox class RecordProcessors class ActiveRecordProcessor < RailsTransactionalOutbox::RecordProcessors::BaseProcessor ACTIVE_RECORD_CONTEXT = "active_record" private_constant :ACTIVE_RECORD_CONTEXT def self.context ACTIVE_RECORD_CONTEXT end def applies?(record) record.context == ACTIVE_RECORD_CONTEXT end def call(record) model = record.infer_model if model.nil? if RailsTransactionalOutbox.configuration.raise_not_found_model_error? raise CouldNotFindModelError.new(record) end 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 class CouldNotFindModelError < StandardError attr_reader :record def initialize(record) super() @record = record end def to_s "could not find model for outbox record: #{record.id}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-transactional-outbox-0.3.1 | lib/rails_transactional_outbox/record_processors/active_record_processor.rb |