Class: Spree::DistributedAmountsHandler
- Inherits:
-
Object
- Object
- Spree::DistributedAmountsHandler
- Defined in:
- app/models/spree/distributed_amounts_handler.rb
Instance Attribute Summary collapse
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#total_amount ⇒ Object
readonly
Returns the value of attribute total_amount.
Instance Method Summary collapse
-
#amount(line_item) ⇒ BigDecimal
The weighted adjustment for this line_item.
-
#initialize(line_items, total_amount) ⇒ DistributedAmountsHandler
constructor
A new instance of DistributedAmountsHandler.
Constructor Details
#initialize(line_items, total_amount) ⇒ DistributedAmountsHandler
Returns a new instance of DistributedAmountsHandler.
7 8 9 10 |
# File 'app/models/spree/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_items ⇒ Object (readonly)
Returns the value of attribute line_items.
5 6 7 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 5 def line_items @line_items end |
#total_amount ⇒ Object (readonly)
Returns the value of attribute total_amount.
5 6 7 |
# File 'app/models/spree/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.
14 15 16 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 14 def amount(line_item) distributed_amounts[line_item.id].to_d end |