class ContentDriven::Page
ContentDriven
defines a tree of content. Page
is the base class. A Page
has a parent and zero or more children
Attributes
date[RW]
parent[RW]
title[RW]
url[RW]
Public Class Methods
inherited(subclass)
click to toggle source
new(&block)
click to toggle source
# File lib/content_driven/page.rb, line 24 def initialize &block if block_given? self.instance_eval &block end self.class.call_after_hooks end
Public Instance Methods
add_child(key, page = nil)
click to toggle source
Add a child page. You will seldom need to call this directly. Instead use add_blog or add_article
# File lib/content_driven/page.rb, line 33 def add_child key, page = nil if key.is_a? Page page, key = key, (self.keys.length + 1).to_sym end page.parent = self page.url = key self[key] = page end
children()
click to toggle source
# File lib/content_driven/page.rb, line 52 def children self end
root?()
click to toggle source
Is this a root page, i.e. it has no parent?
# File lib/content_driven/page.rb, line 43 def root? self.parent.nil? end
to_sym()
click to toggle source
Returns the URL fragment as a symbol, or :root if it is the root page
# File lib/content_driven/page.rb, line 48 def to_sym root? ? :root : self.url.to_sym end