Class: Browser::Middleware::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/browser/middleware/context.rb,
lib/browser/middleware/context/additions.rb,
lib/browser/middleware/context/url_methods.rb

Defined Under Namespace

Modules: Additions, UrlMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
13
14
15
# File 'lib/browser/middleware/context.rb', line 8

def initialize(request)
  @request = request

  @browser = Browser.new(
    request.user_agent,
    accept_language: request.env["HTTP_ACCEPT_LANGUAGE"]
  )
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



6
7
8
# File 'lib/browser/middleware/context.rb', line 6

def browser
  @browser
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/browser/middleware/context.rb', line 6

def request
  @request
end

Instance Method Details

#redirect_to(path) ⇒ Object



17
18
19
# File 'lib/browser/middleware/context.rb', line 17

def redirect_to(path)
  throw :redirected, path.to_s
end