Class: Cookie::Header

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(cookie, attributes = Attribute::Set::EMPTY) ⇒ Header



16
17
18
# File 'lib/cookie/header.rb', line 16

def initialize(cookie, attributes = Attribute::Set::EMPTY)
  super
end

Class Method Details

.build(name, value, attributes) ⇒ Object



12
13
14
# File 'lib/cookie/header.rb', line 12

def self.build(name, value, attributes)
  new(Cookie.new(name, value), attributes)
end

Instance Method Details

#deleteObject



44
45
46
# File 'lib/cookie/header.rb', line 44

def delete
  new(Empty.new(cookie.name), attributes.merge(Attribute::Expired))
end

#http_onlyObject



40
41
42
# File 'lib/cookie/header.rb', line 40

def http_only
  with_attribute(Attribute::HttpOnly.instance)
end

#secureObject



36
37
38
# File 'lib/cookie/header.rb', line 36

def secure
  with_attribute(Attribute::Secure.instance)
end

#to_sObject



48
49
50
# File 'lib/cookie/header.rb', line 48

def to_s
  "#{cookie}#{attributes}"
end

#with_domain(domain) ⇒ Object



20
21
22
# File 'lib/cookie/header.rb', line 20

def with_domain(domain)
  with_attribute(Attribute::Domain.new(domain))
end

#with_expires(time) ⇒ Object



32
33
34
# File 'lib/cookie/header.rb', line 32

def with_expires(time)
  with_attribute(Attribute::Expires.new(time))
end

#with_max_age(seconds) ⇒ Object



28
29
30
# File 'lib/cookie/header.rb', line 28

def with_max_age(seconds)
  with_attribute(Attribute::MaxAge.new(seconds))
end

#with_path(path) ⇒ Object



24
25
26
# File 'lib/cookie/header.rb', line 24

def with_path(path)
  with_attribute(Attribute::Path.new(path))
end