Sha256: 22b933131c5605a73677cce8bb6c8a2c7f8555275150e3646720e356d66ac5ce

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

module Shoppr
  class Category
    
    attr_accessor :attributes, :products
    
    def initialize(cat_mash)        
      Shoppr.map_mash_attrs(self, cat_mash)
      
      if self.attributes
        if self.attributes.attribute
          @attributes = self.attributes.attribute.map {|attribute| Attribute.new(attribute) } 
        else
          @attributes = []
        end
      else
        @attributes = []
      end
    
      if self.items
        if self.items.product.is_a?(Array)
          @products = self.items.product.map {|product| Product.new(product) } 
        else
          @products = self.items.product ? [Product.new(self.items.product)] : []
        end
      else
        @products = []
      end
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppr-0.2.3 lib/shoppr/category.rb