Sha256: 6e8389d62e27d46319b6e1f43360ed829f6ceb0b0874ca9ab4fdb7d27b3a85f9

Contents?: true

Size: 770 Bytes

Versions: 11

Compression:

Stored size: 770 Bytes

Contents

module Workarea
  module Pricing
    class Discount
      # Represents an instance of redemption for a {Discount}.
      # Used for calculating single use discounts.
      #
      class Redemption
        include ApplicationDocument

        # @!attribute email
        #   @return [String] the email that received the discount
        #
        field :email, type: String

        # @!attribute discount
        #   @return [Discount] the discount
        #
        belongs_to :discount,
          class_name: 'Workarea::Pricing::Discount'

        index({ discount_id: 1, email: 1 })

        before_validation :downcase_email

        private

        def downcase_email
          self.email = email.downcase if email.present?
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
workarea-core-3.4.22 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.21 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.20 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.19 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.18 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.17 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.16 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.15 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.14 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.13 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.12 app/models/workarea/pricing/discount/redemption.rb