Class: Sprockets::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets-rack/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sprockets-rack/middleware.rb', line 2

def initialize(app, options = {})
  @app = app
  @config_files = options.delete(:config_files) ||
    options.delete(:config_file).to_a
  @options = options

  if @config_files.empty?
    if @options.include? :root
      if File.exist? default_config_file
        @config_files = [default_config_file] 
      end
    else
      raise ArgumentError, "Sprockets::Middleware needs :root option."
    end
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/sprockets-rack/middleware.rb', line 19

def call(env)
  if env['PATH_INFO'] == configuration[:path]
    response
  else
    @app.call(env)
  end
end