Class: Category

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/lokka/category.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_by_fuzzy_slug(str) ⇒ Object



17
18
19
20
# File 'lib/lokka/category.rb', line 17

def self.get_by_fuzzy_slug(str)
  ret = first(:slug => str)
  ret.blank? ? get(str) : ret
end

Instance Method Details

#fuzzy_slugObject



22
23
24
# File 'lib/lokka/category.rb', line 22

def fuzzy_slug
  slug.blank? ? id : slug
end


26
27
28
29
30
31
32
# File 'lib/lokka/category.rb', line 26

def link
  cats = [fuzzy_slug]
  ancestors.each do |ancestor|
    cats.unshift ancestor.fuzzy_slug
  end
  "/category/#{cats.join('/')}/"
end