Class: Spree::DistributedAmountsHandler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_itemObject (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

#orderObject (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_amountObject (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

#amountFloat

Returns the weighted adjustment for the initialized line item

Returns:

  • (Float)

    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