summaryrefslogtreecommitdiff
path: root/app/services/design_management/on_success_callbacks.rb
blob: be55890a02dd29fff700e6a0f99f1381f0224645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module DesignManagement
  module OnSuccessCallbacks
    def on_success(&block)
      success_callbacks.push(block)
    end

    def success(*_)
      while cb = success_callbacks.pop
        cb.call
      end

      super
    end

    private

    def success_callbacks
      @success_callbacks ||= []
    end
  end
end