summaryrefslogtreecommitdiff
path: root/app/models/solidus_subscriptions/installment_detail.rb
blob: cfd4e70c9d0a9a792315e3f53a12ce9a5543c393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This class represents a single attempt to fulfill an installment. It will
# indicate the result of that attempt.
module SolidusSubscriptions
  class InstallmentDetail < ActiveRecord::Base
    belongs_to(
      :installment,
      class_name: 'SolidusSubscriptions::Installment',
      inverse_of: :details
    )

    belongs_to(:order, class_name: '::Spree::Order', optional: true)

    validates :installment, presence: true
    alias_attribute :successful, :success

    # Was the attempt at fulfilling this installment a failure?
    #
    # @return [Boolean]
    def failed?
      !success
    end
  end
end