Class: Edi::Wayfair::ListingGenerator::Attributes::Material
- Inherits:
-
BaseAttribute
- Object
- BaseAttribute
- Edi::Wayfair::ListingGenerator::Attributes::Material
- Defined in:
- app/services/edi/wayfair/listing_generator/attributes/material.rb
Overview
Maps material from Item to Wayfair's Material attribute
Taxonomy Attribute ID: 880
Datatype: MULTI_CHOICE
Constant Summary collapse
- MATERIAL_MAP =
Common material mappings
{ 'aluminum' => 'Aluminum', 'aluminium' => 'Aluminum', 'steel' => 'Steel', 'stainless_steel' => 'Stainless Steel', 'stainless steel' => 'Stainless Steel', 'plastic' => 'Plastic', 'abs' => 'Plastic', 'glass' => 'Glass', 'ceramic' => 'Ceramic', 'copper' => 'Copper', 'brass' => 'Brass', 'iron' => 'Iron', 'cast_iron' => 'Cast Iron', 'cast iron' => 'Cast Iron', 'wood' => 'Wood', 'metal' => 'Metal', 'carbon_steel' => 'Carbon Steel', 'carbon steel' => 'Carbon Steel' }.with_indifferent_access.freeze
Constants inherited from BaseAttribute
Instance Attribute Summary
Attributes inherited from BaseAttribute
#attribute_definition, #catalog_item, #item, #taxonomy_attribute_id, #wayfair_schema
Instance Method Summary collapse
Methods inherited from BaseAttribute
attribute_name, #attribute_title, #build, #build_attribute_hash, #can_build?, #custom_values_allowed?, #datatype, #fetch_value, #format_boolean, #format_decimal, #initialize, #map_unit, #possible_values, #requirement, set_taxonomy_attribute_id, taxonomy_attribute_id, #valid_value?
Constructor Details
This class inherits a constructor from Edi::Wayfair::ListingGenerator::Attributes::BaseAttribute
Instance Method Details
#value ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/services/edi/wayfair/listing_generator/attributes/material.rb', line 32 def value materials = fetch_value(:materials) || fetch_value(:material) return nil if materials.blank? # Handle array or single value materials = [materials] unless materials.is_a?(Array) # Map each material materials.map do |mat| mapped = MATERIAL_MAP[mat.to_s.downcase.strip] mapped || mat.to_s.titleize end.compact.uniq end |