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.



39
40
41
# File 'lib/rack/contrib/cookies.rb', line 39

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

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