Class: Spree::Stock::InventoryUnitsFinalizer
- Inherits:
-
Object
- Object
- Spree::Stock::InventoryUnitsFinalizer
- Defined in:
- app/models/spree/stock/inventory_units_finalizer.rb
Overview
Service class to finalize inventory units, it means unstock the desired quantity from related stock item and updates the given inventory units to not be pending.
Instance Attribute Summary collapse
- #inventory_units ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(inventory_units) ⇒ InventoryUnitsFinalizer
constructor
A new instance of InventoryUnitsFinalizer.
-
#run! ⇒ Object
Finalize the inventory units, unstock and mark them as not pending.
Constructor Details
#initialize(inventory_units) ⇒ InventoryUnitsFinalizer
Returns a new instance of InventoryUnitsFinalizer.
13 14 15 |
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 13 def initialize(inventory_units) @inventory_units = inventory_units end |
Instance Attribute Details
#inventory_units ⇒ Object (readonly)
10 11 12 |
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 10 def inventory_units @inventory_units end |
Instance Method Details
#run! ⇒ Object
Finalize the inventory units, unstock and mark them as not pending.
18 19 20 21 22 23 |
# File 'app/models/spree/stock/inventory_units_finalizer.rb', line 18 def run! Spree::InventoryUnit.transaction do unstock_inventory_units finalize_inventory_units end end |