Class: SolidusFriendlyPromotions::Benefits::AdjustLineItemQuantityGroups::Item
- Inherits:
-
Object
- Object
- SolidusFriendlyPromotions::Benefits::AdjustLineItemQuantityGroups::Item
- Defined in:
- app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb
Overview
Used specifically for PercentOnLineItem calculator. That calculator uses ‘line_item.amount`, however we might not necessarily want to discount the entire amount. This class allows us to determine the discount per quantity and then calculate the adjustment amount the way we normally do for flat rate adjustments.
Instance Attribute Summary collapse
-
#line_item ⇒ Object
readonly
Returns the value of attribute line_item.
Instance Method Summary collapse
- #currency ⇒ Object
- #discountable_amount ⇒ Object (also: #amount)
-
#initialize(line_item) ⇒ Item
constructor
A new instance of Item.
- #order ⇒ Object
Constructor Details
#initialize(line_item) ⇒ Item
Returns a new instance of Item.
89 90 91 |
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 89 def initialize(line_item) @line_item = line_item end |
Instance Attribute Details
#line_item ⇒ Object (readonly)
Returns the value of attribute line_item.
88 89 90 |
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 88 def line_item @line_item end |
Instance Method Details
#currency ⇒ Object
102 103 104 |
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 102 def currency @line_item.currency end |
#discountable_amount ⇒ Object Also known as: amount
93 94 95 |
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 93 def discountable_amount @line_item.discountable_amount / @line_item.quantity.to_d end |
#order ⇒ Object
98 99 100 |
# File 'app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb', line 98 def order @line_item.order end |