Class: Spree::DistributedAmountsHandler
- Inherits:
-
Object
- Object
- Spree::DistributedAmountsHandler
- Defined in:
- app/models/spree/distributed_amounts_handler.rb
Instance Attribute Summary collapse
-
#line_item ⇒ Object
readonly
Returns the value of attribute line_item.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#total_amount ⇒ Object
readonly
Returns the value of attribute total_amount.
Instance Method Summary collapse
-
#amount ⇒ Float
The weighted adjustment for the initialized line item.
-
#initialize(line_item, total_amount) ⇒ DistributedAmountsHandler
constructor
A new instance of DistributedAmountsHandler.
Constructor Details
#initialize(line_item, total_amount) ⇒ DistributedAmountsHandler
Returns a new instance of DistributedAmountsHandler.
5 6 7 8 9 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 5 def initialize(line_item, total_amount) @line_item = line_item @order = line_item.order @total_amount = total_amount end |
Instance Attribute Details
#line_item ⇒ Object (readonly)
Returns the value of attribute line_item.
3 4 5 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 3 def line_item @line_item end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
3 4 5 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 3 def order @order end |
#total_amount ⇒ Object (readonly)
Returns the value of attribute total_amount.
3 4 5 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 3 def total_amount @total_amount end |
Instance Method Details
#amount ⇒ Float
Returns the weighted adjustment for the initialized line item.
12 13 14 |
# File 'app/models/spree/distributed_amounts_handler.rb', line 12 def amount distributed_amounts[@line_item.id].to_f end |