Sha256: e5bdc3764f12c229e67ecbc63f397988c283f1b3c317af9a7e39cff9a1b3d029

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

require "forwardable"

module Sitepress
  # Configuration object for rails application.
  class RailsConfiguration
    # Store in ./app/content by default.
    DEFAULT_SITE_ROOT = "app/content".freeze

    attr_accessor :site, :parent_engine, :routes, :cache_resources

    # Delegates configuration points into the Sitepress site.
    extend Forwardable
    def_delegators :site, :cache_resources, :cache_resources=, :cache_resources?

    # Set defaults.
    def initialize
      self.routes = true
      self.parent_engine = Rails.application
      self.cache_resources = !!parent_engine.config.cache_classes
    end

    def site
      @site ||= Site.new(root_path: default_root).tap do |site|
        site.resources_pipeline << Extensions::PartialsRemover.new
        site.resources_pipeline << Extensions::RailsRequestPaths.new
      end
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitepress-rails-0.1.22 lib/sitepress/rails_configuration.rb
sitepress-rails-0.1.21 lib/sitepress/rails_configuration.rb