Class: Kms::Page

Inherits:
ActiveRecord::Base
  • Object
show all
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

Methods included from Positioned

#set_position

Methods included from CompileTemplates

#register_id

Instance Method Details

#build_fullpathObject



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_itemsObject

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

Returns:

  • (Boolean)


22
23
24
# File 'app/models/kms/page.rb', line 22

def index?
  slug == INDEX_SLUG
end