Class: Gemgento::InventoryValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Gemgento::InventoryValidator
- Defined in:
- app/validators/gemgento/inventory_validator.rb
Instance Method Summary collapse
-
#validate(line_item) ⇒ Object
Validate LineItem Product inventory levels.
Instance Method Details
#validate(line_item) ⇒ Object
Validate LineItem Product inventory levels.
7 8 9 10 11 |
# File 'app/validators/gemgento/inventory_validator.rb', line 7 def validate(line_item) unless line_item.product.in_stock?(line_item.qty_ordered, line_item.itemizable.store) line_item.errors.add(:base, 'Requested quantity is not available') end end |