diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-30 06:13:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-30 06:13:04 +0300 |
commit | 2a6b543cbf045b7d480a21c1c77fd4f0243a6437 (patch) | |
tree | 6b016d1a68d7d642712a9603a3c57602b1702a32 /lib | |
parent | cb29b873b658591f571b4041717090ddceff2e0f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/after_commit_queue.rb | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb deleted file mode 100644 index cbeaea97951..00000000000 --- a/lib/after_commit_queue.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -module AfterCommitQueue - extend ActiveSupport::Concern - - included do - after_commit :_run_after_commit_queue - after_rollback :_clear_after_commit_queue - end - - def run_after_commit(&block) - _after_commit_queue << block if block - - true - end - - def run_after_commit_or_now(&block) - if ApplicationRecord.inside_transaction? - if ActiveRecord::Base.connection.current_transaction.records&.include?(self) - run_after_commit(&block) - else - # If the current transaction does not include this record, we can run - # the block now, even if it queues a Sidekiq job. - Sidekiq::Worker.skipping_transaction_check do - instance_eval(&block) - end - end - else - instance_eval(&block) - end - - true - end - - protected - - def _run_after_commit_queue - while action = _after_commit_queue.pop - self.instance_eval(&action) - end - end - - def _after_commit_queue - @after_commit_queue ||= [] - end - - def _clear_after_commit_queue - _after_commit_queue.clear - end -end |