Sha256: d507bc4e9e5a6db8aca2f6d2af69aa8932701e9aee1d877893c93a13827a13ca
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
# encoding: utf-8 module BusinessCatalyst module CSV # Example: Chain*|5|N:Rope Chain||US/0,Box Chain||US/5,Snake Chain||US/5;Length*|5|N:16 inch||US/0,18 inch||US/0,20 inch||US/0,24 inch||US/0 # # Name1REQ|display_as|keep_stock:Option1.name|Option1.image|Option1.price,Option2.name|...;Name2... class ProductAttributesTransformer < Transformer def transform if input.kind_of?(String) input elsif input attributes.map {|attribute| name = BusinessCatalyst.sanitize_catalog_name(attribute.name) required = attribute.required ? '*' : '' display_as = attribute.display_as.to_i keep_stock = BooleanTransformer.transform(attribute.keep_stock) text = ["#{name}#{required}", display_as, keep_stock].join("|") text << ":" text << attribute.options.map {|option| name = BusinessCatalyst.sanitize_catalog_name(option.name.to_s) image = option.image.to_s.strip price = CurrencyTransformer.transform(option.price) [name, image, price].join("|") }.join(",") text }.join(";") end end def attributes if input.kind_of?(Array) input.compact else [input].compact end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems