Sha256: 61d4fc0cbbee9f627c0b949eb2bd6450fde5c34e3de49c956ffd0f4e85844bdc

Contents?: true

Size: 953 Bytes

Versions: 14

Compression:

Stored size: 953 Bytes

Contents

require 'xml/mapping'
require_relative '../resource'

module Resync
  module SitemapIndex
    include ::XML::Mapping

    def self.included(base)
      base.extend(ClassMethods)

      base.use_mapping :sitemapindex
      base.root_element_name 'sitemapindex'
      base.array_node :resources, 'sitemap', class: Resource, default_value: [], sub_mapping: :_default
    end

    # Ensures that an index is always written as a +<sitemapindex>+.
    # Overrides +::XML::Mapping.save_to_xml+.
    def save_to_xml(options = { mapping: :_default })
      options = options.merge(mapping: :sitemapindex)
      super(options)
    end

    # Ensures that an index is always read as a +<sitemapindex>+.
    # Overrides +::XML::Mapping::ClassMethods.load_from_xml+.
    module ClassMethods
      def load_from_xml(xml, options = { mapping: :_default })
        options = options.merge(mapping: :sitemapindex)
        super(xml, options)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
resync-0.4.1 lib/resync/shared/sitemap_index.rb
resync-0.4.0 lib/resync/shared/sitemap_index.rb
resync-0.3.4 lib/resync/shared/sitemap_index.rb
resync-0.3.3 lib/resync/shared/sitemap_index.rb
resync-0.3.2 lib/resync/shared/sitemap_index.rb
resync-0.3.1 lib/resync/shared/sitemap_index.rb
resync-0.3.0 lib/resync/shared/sitemap_index.rb
resync-0.2.2 lib/resync/shared/sitemap_index.rb
resync-0.2.1 lib/resync/shared/sitemap_index.rb
resync-0.2.0 lib/resync/shared/sitemap_index.rb
resync-0.1.3 lib/resync/shared/sitemap_index.rb
resync-0.1.2 lib/resync/shared/sitemap_index.rb
resync-0.1.1 lib/resync/shared/sitemap_index.rb
resync-0.1.0 lib/resync/shared/sitemap_index.rb