Class: SolidusPromotions::Benefits::AdjustLineItemQuantityGroups::Item
- Inherits:
-
Object
- Object
- SolidusPromotions::Benefits::AdjustLineItemQuantityGroups::Item
- Defined in:
- app/models/solidus_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.
88 89 90 |
# File 'app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb', line 88 def initialize(line_item) @line_item = line_item end |
Instance Attribute Details
#line_item ⇒ Object (readonly)
Returns the value of attribute line_item.
86 87 88 |
# File 'app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb', line 86 def line_item @line_item end |
Instance Method Details
#currency ⇒ Object
101 102 103 |
# File 'app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb', line 101 def currency @line_item.currency end |
#discountable_amount ⇒ Object Also known as: amount
92 93 94 |
# File 'app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb', line 92 def discountable_amount @line_item.discountable_amount / @line_item.quantity.to_d end |
#order ⇒ Object
97 98 99 |
# File 'app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb', line 97 def order @line_item.order end |