Class: SolidusFriendlyPromotions::DistributedAmountsHandler

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_friendly_promotions/distributed_amounts_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_items, total_amount) ⇒ DistributedAmountsHandler

Returns a new instance of DistributedAmountsHandler.



7
8
9
10
# File 'app/models/solidus_friendly_promotions/distributed_amounts_handler.rb', line 7

def initialize(line_items, total_amount)
  @line_items = line_items
  @total_amount = total_amount
end

Instance Attribute Details

#line_itemsObject (readonly)

Returns the value of attribute line_items.



5
6
7
# File 'app/models/solidus_friendly_promotions/distributed_amounts_handler.rb', line 5

def line_items
  @line_items
end

#total_amountObject (readonly)

Returns the value of attribute total_amount.



5
6
7
# File 'app/models/solidus_friendly_promotions/distributed_amounts_handler.rb', line 5

def total_amount
  @total_amount
end

Instance Method Details

#amount(line_item) ⇒ BigDecimal

Returns the weighted adjustment for this line_item.

Parameters:

  • line_item (LineItem)

    one of the line_items distributed over

Returns:

  • (BigDecimal)

    the weighted adjustment for this line_item



14
15
16
# File 'app/models/solidus_friendly_promotions/distributed_amounts_handler.rb', line 14

def amount(line_item)
  distributed_amounts[line_item.id].to_d
end