Class: Cookie::Header
- Inherits:
-
Object
- Object
- Cookie::Header
- Includes:
- Adamantium::Flat
- Defined in:
- lib/cookie/header.rb,
lib/cookie/header/attribute.rb
Overview
Models a transient, new cookie on the server that can be serialized into an HTTP ‘Set-Cookie’ header
Defined Under Namespace
Classes: Attribute
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #http_only ⇒ Object
-
#initialize(cookie, attributes = Attribute::Set::EMPTY) ⇒ Header
constructor
A new instance of Header.
- #secure ⇒ Object
- #to_s ⇒ Object
- #with_domain(domain) ⇒ Object
- #with_expires(time) ⇒ Object
- #with_max_age(seconds) ⇒ Object
- #with_path(path) ⇒ Object
Constructor Details
Class Method Details
.build(name, value, attributes) ⇒ Object
18 19 20 |
# File 'lib/cookie/header.rb', line 18 def self.build(name, value, attributes) new(Cookie.new(name, value), attributes) end |
Instance Method Details
#delete ⇒ Object
50 51 52 |
# File 'lib/cookie/header.rb', line 50 def delete new(Empty.new(.name), attributes.merge(Attribute::Expired)) end |
#http_only ⇒ Object
46 47 48 |
# File 'lib/cookie/header.rb', line 46 def http_only with_attribute(Attribute::HttpOnly.instance) end |
#secure ⇒ Object
42 43 44 |
# File 'lib/cookie/header.rb', line 42 def secure with_attribute(Attribute::Secure.instance) end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/cookie/header.rb', line 54 def to_s "#{}#{attributes}" end |
#with_domain(domain) ⇒ Object
26 27 28 |
# File 'lib/cookie/header.rb', line 26 def with_domain(domain) with_attribute(Attribute::Domain.new(domain)) end |
#with_expires(time) ⇒ Object
38 39 40 |
# File 'lib/cookie/header.rb', line 38 def with_expires(time) with_attribute(Attribute::Expires.new(time)) end |