Sha256: d8e856d5850b5fef0f8e45466ceca0dc12da7448fcfc4d54f13d150d74674a63

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

module Gemgento
  class InventoryValidator < ActiveModel::Validator

    # Validate LineItem Product inventory levels.
    #
    # @param line_item [Gemgento::LineItem]
    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/validators/gemgento/inventory_validator.rb