class EasySitemap::Generator
Public Class Methods
new(entities_scope, options = {})
click to toggle source
# File lib/easy_sitemap/generator.rb, line 4 def initialize(entities_scope, options = {}) @entities_scope = entities_scope @options = options end
Public Instance Methods
to_xml()
click to toggle source
# File lib/easy_sitemap/generator.rb, line 9 def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.urlset do @entities_scope.find_each(batch_size: 1) do |entity| xml.url do xml.loc url(entity) if entity.respond_to?(:updated_at) xml.lastmod entity.updated_at elsif entity.respond_to?(:updated_on) xml.lastmod entity.updated_on end end end end end builder.to_xml end
Protected Instance Methods
url(entity)
click to toggle source
# File lib/easy_sitemap/generator.rb, line 29 def url(entity) u = [@options[:host] || "http://localhost:3000"] u << case entity when Issue "issues" end u << entity.id u.join("/") end