Class: Categoryz3::Category

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/categoryz3/category.rb

Instance Method Summary collapse

Instance Method Details

#pathObject

Public: Returns the full categories path from the root category until this category

Example:

subcategory3.path
#=> [category, subcategory1, subcategory2, subcategory3]


23
24
25
# File 'app/models/categoryz3/category.rb', line 23

def path
  @path_array ||= parent ? [parent.path, self].flatten : [self]
end

#reprocess_items!Object

Public: Reprocess all items from this category



29
30
31
32
33
# File 'app/models/categoryz3/category.rb', line 29

def reprocess_items!
  @path_array = nil
  self.direct_items.each { |item| item.reprocess_child_items! }
  self.children.each     { |category| category.reprocess_items! }
end