Class: SolidusFriendlyPromotions::FriendlyPromotionAdjuster::ChooseDiscounts
- Inherits:
-
Object
- Object
- SolidusFriendlyPromotions::FriendlyPromotionAdjuster::ChooseDiscounts
- Defined in:
- app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb
Instance Attribute Summary collapse
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(discounts) ⇒ ChooseDiscounts
constructor
A new instance of ChooseDiscounts.
Constructor Details
#initialize(discounts) ⇒ ChooseDiscounts
Returns a new instance of ChooseDiscounts.
8 9 10 |
# File 'app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb', line 8 def initialize(discounts) @discounts = discounts end |
Instance Attribute Details
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
6 7 8 |
# File 'app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb', line 6 def discounts @discounts end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb', line 12 def call Array.wrap( discounts.min_by do |discount| [discount.amount, -discount.source&.id.to_i] end ) end |