Class: Kms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Kms::Page
- Includes:
- CompileTemplates, Positioned, Liquor::Dropable
- Defined in:
- app/models/kms/page.rb
Constant Summary collapse
- INDEX_SLUG =
"index".freeze
- INDEX_FULLPATH =
""
Instance Method Summary collapse
- #build_fullpath ⇒ Object
-
#fetch_item!(slug) ⇒ Object
fetch item by slug.
-
#fetch_items ⇒ Object
fetch items for templatable page.
- #index? ⇒ Boolean
Methods included from Positioned
Methods included from CompileTemplates
Instance Method Details
#build_fullpath ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/models/kms/page.rb', line 26 def build_fullpath if index? self.fullpath = INDEX_FULLPATH # self.slug else slugs = (ancestors + [self]).map(&:slug) slugs.shift unless slugs.size == 1 self.fullpath = File.join slugs.compact end end |
#fetch_item!(slug) ⇒ Object
fetch item by slug
42 43 44 45 |
# File 'app/models/kms/page.rb', line 42 def fetch_item!(slug) return nil unless templatable? templatable_type.constantize.find_by_slug!(slug) end |
#fetch_items ⇒ Object
fetch items for templatable page
37 38 39 |
# File 'app/models/kms/page.rb', line 37 def fetch_items templatable_type.constantize.all end |
#index? ⇒ Boolean
22 23 24 |
# File 'app/models/kms/page.rb', line 22 def index? slug == INDEX_SLUG end |