Module: Merb::CookiesMixin

Defined in:
lib/merb-core/dispatch/cookies.rb

Defined Under Namespace

Modules: RequestMixin

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/merb-core/dispatch/cookies.rb', line 96

def self.included(base)
  # Allow per-controller default cookie domains (see callback below)
  base.class_inheritable_accessor :_default_cookie_domain
  base._default_cookie_domain = Merb::Config[:default_cookie_domain]
  
  # Add a callback to enable Set-Cookie headers
  base._after_dispatch_callbacks << lambda do |c|
    headers = c.request.cookies.extract_headers("domain" => c._default_cookie_domain)
    c.headers.update(headers)
  end
end

Instance Method Details

#cookiesObject

Returns

Merb::Cookies

A new Merb::Cookies instance representing the cookies that came in from the request object

Notes

Headers are passed into the cookie object so that you can do:

cookies[:foo] = "bar"

:api: public



118
119
120
# File 'lib/merb-core/dispatch/cookies.rb', line 118

def cookies
  request.cookies
end