Class: Fewer::MiddleWare

Inherits:
Object
  • Object
show all
Defined in:
lib/fewer/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, name, options = {}) ⇒ MiddleWare

Returns a new instance of MiddleWare.



3
4
5
6
7
8
# File 'lib/fewer/middleware.rb', line 3

def initialize(app, name, options = {})
  @name = name
  @options = options
  @app = app
  @mount = @options[:mount]
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/fewer/middleware.rb', line 10

def call(env)
  if env['PATH_INFO'] =~ /^#{@mount}/
    App.new(@name, @options).call(env)
  else
    @app.call(env)
  end
end