Class: Platform::Category
- Defined in:
- app/models/platform/category.rb
Overview
– Copyright © 2011 Michael Berkovich
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++
Class Method Summary collapse
Instance Method Summary collapse
- #featured_application_categories ⇒ Object
- #full_name ⇒ Object
- #regular_application_categories ⇒ Object
- #root? ⇒ Boolean
Class Method Details
.category_id_by_keyword(keyword) ⇒ Object
35 36 37 38 39 |
# File 'app/models/platform/category.rb', line 35 def self.category_id_by_keyword(keyword) cat = find_by_keyword(keyword) return nil if not cat cat.id end |
Instance Method Details
#featured_application_categories ⇒ Object
45 46 47 |
# File 'app/models/platform/category.rb', line 45 def featured_application_categories Platform::ApplicationCategory.find(:all, :conditions => ["category_id = ? and featured = ?", self.id, true], :order => "position") end |
#full_name ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/platform/category.rb', line 53 def full_name @full_name ||= begin names = [name] p = parent while p do names << p.name p = p.parent end names.reverse.join(" » ") end end |
#regular_application_categories ⇒ Object
49 50 51 |
# File 'app/models/platform/category.rb', line 49 def regular_application_categories Platform::ApplicationCategory.find(:all, :conditions => ["category_id = ? and (featured is NULL or featured = ?)", self.id, false], :order => "position") end |
#root? ⇒ Boolean
41 42 43 |
# File 'app/models/platform/category.rb', line 41 def root? keyword == 'root' end |