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

# This service class is intended to provide callback behaviour to handle
# the case where an installment cannot be processed due to lack of stock.
module SolidusSubscriptions
  class OutOfStockDispatcher < Dispatcher
    def dispatch
      installments.each(&:out_of_stock)
      super
    end

    private

    def message
      "
      The following installments cannot be fulfilled due to lack of stock:
      #{installments.map(&:id).join(', ')}.
      "
    end
  end
end