Sha256: eb5d35891baa2e319f93cc46bce1e8cb3407e837d1be3af9191f520728474606

Contents?: true

Size: 842 Bytes

Versions: 23

Compression:

Stored size: 842 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 })
        index({ discount_id: 1, created_at: -1 }, { background: true })

        before_validation :downcase_email

        private

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.44 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.43 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.42 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.41 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.40 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.39 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.38 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.37 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.36 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.35 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.34 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.33 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.32 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.31 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.30 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.29 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.28 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.27 app/models/workarea/pricing/discount/redemption.rb
workarea-core-3.4.26 app/models/workarea/pricing/discount/redemption.rb