Sha256: 56447524dea6fc986b4245070e4e954a2d425ecb5a22bcd26a15da2a9a985617

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Mascot
  # Configuration object for rails application.
  class RailsConfiguration
    # Store in ./app/pages by default.
    DEFAULT_SITEMAP_ROOT = "app/pages".freeze

    attr_accessor :sitemap, :resources, :parent_engine, :routes, :cache_resources, :partials

    # Set defaults.
    def initialize
      @routes = true
      @parent_engine = Rails.application
      @cache_resources = @parent_engine.config.cache_classes
      @partials = false
    end

    def sitemap
      @sitemap ||= Sitemap.new(root: default_root).tap do |sitemap|
        sitemap.extensions << Extensions::PartialsRemover.new unless partials
        sitemap.extensions << Extensions::RailsRequestPaths.new
      end
    end

    def resources
      # Production will cache resources globally. This drastically speeds up
      # the speed at which resources are served, but if they change it won't be updated.
      @resources = nil unless cache_resources?
      @resources ||= sitemap.resources
    end

    def cache_resources?
      !!@cache_resources
    end

    private
    def default_root
      Rails.root.join(DEFAULT_SITEMAP_ROOT)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mascot-rails-0.1.10 lib/mascot/rails_configuration.rb
mascot-rails-0.1.9 lib/mascot/rails_configuration.rb
mascot-rails-0.1.8 lib/mascot/rails_configuration.rb