class BBMB::Util::CustomerImporter
Constants
- CUSTOMER_MAP
Public Instance Methods
import_record(record)
click to toggle source
# File lib/bbmb/util/csv_importer.rb, line 50 def import_record(record) customer_id = string(record[0]) ean13 = string(record[1]) return unless(/^\d+$/.match(customer_id)) customer = Model::Customer.find_by_customer_id(customer_id) if customer.nil? && !ean13.to_s.empty? \ && (customer = Model::Customer.find_by_ean13(ean13) \ || Model::Customer.find_by_customer_id(ean13)) customer.customer_id = customer_id end customer ||= Model::Customer.new(customer_id) CUSTOMER_MAP.each { |idx, name| unless customer.protects? name customer.send("#{name}=", string(record[idx])) end } customer rescue Yus::DuplicateNameError => err @duplicates.push(err) nil end