Class: SolidusFriendlyPromotions::ItemDiscount

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/solidus_friendly_promotions/item_discount.rb

Overview

Simple object used to hold discount data for an item.

This generic object will hold the amount of discount that should be applied to an item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountBigDecimal

the amount of discount applied to the item

Returns:

  • (BigDecimal)

    the current value of amount



13
14
15
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 13

def amount
  @amount
end

#itemObject

Returns the value of attribute item.



15
16
17
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 15

def item
  @item
end

#labelString

information about the discount

Returns:

  • (String)

    the current value of label



13
14
15
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 13

def label
  @label
end

#sourceApplicationRecord

will be used as the source for adjustments

Returns:

  • (ApplicationRecord)

    the current value of source



13
14
15
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 13

def source
  @source
end

#theSpree::LineItem, Spree::Shipment (readonly)

item to be discounted.

Returns:

  • (Spree::LineItem, Spree::Shipment)

    the current value of the



13
14
15
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 13

def the
  @the
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'app/models/solidus_friendly_promotions/item_discount.rb', line 17

def ==(other)
  item == other.item && label == other.label && source == other.source && amount == other.amount
end