Sha256: d161f1c0a9c537501d0d1786983c221a4bca655600ef18ebee5936d63609c093

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

require "forwardable"

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

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

    # Delegates configuration points into the Mascot 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, cache_resources: @cache_resources).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

1 entries across 1 versions & 1 rubygems

Version Path
mascot-rails-0.1.16 lib/mascot/rails_configuration.rb