Sha256: 14a4d3863b0ce5022c49c0590489bf84588d0d387d680cd77ff466cbc468bed3

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

require "active_record"

module AfterCommitExceptionNotification
  def self.callback(exception = nil, &block)
    if block
      @block = block
    elsif @block
      @block.call(exception)
    else
      message = ["After commit failed: #{$!}"].concat $!.backtrace
      ActiveRecord::Base.logger.error(message)
      warn message
    end
  end

  module CommittedWithNotification
    def committed!
      super
    rescue Exception => e # same as active_record/connection_adapters/abstract/database_statements.rb:370
      AfterCommitExceptionNotification.callback(e)
      raise
    end
  end
end

ActiveRecord::Base.send :include, AfterCommitExceptionNotification::CommittedWithNotification

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
after_commit_exception_notification-0.2.0 lib/after_commit_exception_notification.rb