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:



12
13
14
15
16
17
# File 'lib/cms/addressable.rb', line 12

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



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

def cache_parent(section)
  @parent = section
end

#parentObject



19
20
21
22
# File 'lib/cms/addressable.rb', line 19

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

#parent=(sec) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/cms/addressable.rb', line 28

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.



37
38
39
# File 'lib/cms/addressable.rb', line 37

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