Class: Spree::Stock::InventoryValidator Private

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/spree/stock/inventory_validator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#validate(line_item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
7
8
9
10
11
# File 'app/models/spree/stock/inventory_validator.rb', line 4

def validate(line_item)
  if line_item.inventory_units.count != line_item.quantity
    line_item.errors[:inventory] << Spree.t(
      :inventory_not_available,
      item: line_item.variant.name
    )
  end
end