Class: Rack::Cookies

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/contrib/cookies.rb

Defined Under Namespace

Classes: CookieJar

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Cookies

Returns a new instance of Cookies.



37
38
39
# File 'lib/rack/contrib/cookies.rb', line 37

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/rack/contrib/cookies.rb', line 41

def call(env)
  req = Request.new(env)
  env['rack.cookies'] = cookies = CookieJar.new(req.cookies)
  status, headers, body = @app.call(env)
  resp = Response.new(body, status, headers)
  cookies.finish!(resp)
  resp.to_a
end