Sha256: 168387ba436a311149f8755a55d792be517ad58ca7bb4980ea9702ac79067404

Contents?: true

Size: 921 Bytes

Versions: 3

Compression:

Stored size: 921 Bytes

Contents

module Rail
  class Application
    attr_reader :config, :browser, :pipeline

    def initialize
      @config = self.class.config
      @browser = Browser.new(config)
      @pipeline = Pipeline.new(config)
    end

    def call(env)
      request = Request.new(env)
      (browser.accept?(request) ? browser : pipeline).process(request)
    end

    def precompile
      Precompiler.new(pipeline).process(config.precompile)
    end

    def self.inherited(klass)
      klass.config.root = File.expand_path('../..', caller[0].sub(/:.*/, ''))
    end

    def self.config
      @config ||= Support::QueryStruct.new(default_options)
    end

    def self.load_tasks
      Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each do |path|
        Rake::load_rakefile(path)
      end
    end

    private

    def self.default_options
      { gems: [], precompile: [], compress: Rail.env.production?  }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rail-0.1.1 lib/rail/application.rb
rail-0.1.0 lib/rail/application.rb
rail-0.0.8 lib/rail/application.rb