Class: Shoppr::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/shoppr/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cat_mash) ⇒ Category


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/shoppr/category.rb', line 6

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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes


4
5
6
# File 'lib/shoppr/category.rb', line 4

def attributes
  @attributes
end

#productsObject

Returns the value of attribute products


4
5
6
# File 'lib/shoppr/category.rb', line 4

def products
  @products
end