class ProductCollection

Public Instance Methods

find_by_product_code(code) click to toggle source
# File lib/wunder/collections/product_collection.rb, line 2
def find_by_product_code(code)
  each do |product|
    @fetch_product = product if product.product_code == code
  end

  @fetch_product
end
validate_product_code_is_uniq(code) click to toggle source
# File lib/wunder/collections/product_collection.rb, line 10
def validate_product_code_is_uniq(code)
  find_by_product_code(code).nil? ? true : (raise "DuplicateProductCodeError")
end