Sha256: eba5e36abba392af080d75eb9606f7f738539c588b0871473b3c7e162e6c6038

Contents?: true

Size: 584 Bytes

Versions: 5

Compression:

Stored size: 584 Bytes

Contents

class Sitemap
  def self.build(&block)
    if block_given?
      yield(root)
      root.save!
    end

    root.children.each do | node |
     document = node.documents.new
     document.title = node.name.capitalize
     document.save!
    end
    root
  end

  def self.destroy!
    Node.root.try(:destroy)
  end

  def self.cleanup
    # remove nodes which do not exist
  end

  def self.root
    Node.root || Node.create(:name => 'root')
  end

  def self.to_hash
    root.to_hash
  end

  def self.load_from_disk!
    destroy!
    load "#{Rails.root}/config/sitemap.rb"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qwerty-0.0.7.pre app/models/sitemap.rb
qwerty-0.0.5.pre app/models/sitemap.rb
qwerty-0.0.4.pre app/models/sitemap.rb
qwerty-0.0.3.pre app/models/sitemap.rb
qwerty-0.0.1.pre app/models/sitemap.rb