Sha256: b28d1290500091d008d6284f7cd725ca19f4e4ed256f70de894056af08048600

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

# encoding: UTF-8

module Spontaneous::Plugins
  module SiteMap
    extend ActiveSupport::Concern

    # InstanceMethods
    def map_children
      self.children.map { |c| c.map_entry }
    end

    def map_entry
      shallow_map_entry.merge({
        :children => self.children.map {|c| c.shallow_map_entry },
        :generation => self.generation.map {|c| c.shallow_map_entry },
        :ancestors => self.ancestors.map {|c| c.shallow_map_entry },
      })
    end
    def shallow_map_entry
      {
        :id => id,
        :title => fields.title.value,
        :path => path,
        :slug => slug,
        :type => self.class.ui_class,
        :type_id => self.class.schema_id,
        :children => self.children.length,
        :depth => depth
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spontaneous-0.2.0.alpha2 lib/spontaneous/plugins/site_map.rb
spontaneous-0.2.0.alpha1 lib/spontaneous/plugins/site_map.rb