Module: Cms::Addressable

Included in:
Attachment, Link, Page, Section
Defined in:
lib/cms/addressable.rb

Defined Under Namespace

Modules: DeprecatedPageAccessors, LeafNode, NodeAccessors

Instance Method Summary collapse

Instance Method Details

#ancestors(options = {}) ⇒ Array<Addressable]

Returns a list of all Addressable objects that are ancestors to this record.

Parameters:

  • options (Hash) (defaults to: {})
  • [Symbol] (Hash)

    a customizable set of options

Returns:



16
17
18
19
20
21
# File 'lib/cms/addressable.rb', line 16

def ancestors(options={})
  ancestor_nodes = node.ancestors
  ancestors = ancestor_nodes.collect { |node| node.node }
  ancestors << self if options[:include_self]
  ancestors
end

#cache_parent(section) ⇒ Object



28
29
30
# File 'lib/cms/addressable.rb', line 28

def cache_parent(section)
  @parent = section
end

#parentObject



23
24
25
26
# File 'lib/cms/addressable.rb', line 23

def parent
  @parent if @parent
  node ? node.section : nil
end

#parent=(sec) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/cms/addressable.rb', line 32

def parent=(sec)
  if node
    node.move_to_end(sec)
  else
    build_section_node(:node => self, :section => sec)
  end
end

#partial_forObject

Computes the name of the partial used to render this object in the sitemap.



41
42
43
# File 'lib/cms/addressable.rb', line 41

def partial_for
  self.class.name.demodulize.underscore
end