Class: Rack::UserAgent::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/user_agent/filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, config = [], options = {}) ⇒ Filter

Returns a new instance of Filter.



8
9
10
11
12
# File 'lib/rack/user_agent/filter.rb', line 8

def initialize(app, config = [], options = {})
  @app = app
  @browsers = config
  @template = options[:template]
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/rack/user_agent/filter.rb', line 14

def call(env)
  browser = UserAgent.parse(env["HTTP_USER_AGENT"]) if env["HTTP_USER_AGENT"]
  if unsupported?(browser)
    [400, {"Content-Type" => "text/html"}, page(env['rack.locale'], browser)]
  else
    @app.call(env)
  end
end