Class: Rack::UserAgent::Filter
- Inherits:
-
Object
- Object
- Rack::UserAgent::Filter
- Defined in:
- lib/rack/user_agent/filter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, browsers = [], options = {}) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(app, browsers = [], options = {}) ⇒ Filter
Returns a new instance of Filter.
8 9 10 11 12 13 |
# File 'lib/rack/user_agent/filter.rb', line 8 def initialize(app, browsers = [], = {}) @app = app @browsers = browsers @template = [:template] = [:force_with_cookie] end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/user_agent/filter.rb', line 15 def call(env) request = Rack::Request.new(env) browser = UserAgent.parse(env["HTTP_USER_AGENT"]) if env["HTTP_USER_AGENT"] if !(request.) && unsupported?(browser) content = render_page(browser) [400, {"Content-Type" => "text/html", "Content-Length" => content.length.to_s}, content] else @app.call(env) end end |