class Cookie::Header
Models a transient, new cookie on the server that can be serialized into an HTTP 'Set-Cookie' header
Public Class Methods
build(name, value, attributes)
click to toggle source
# File lib/cookie/header.rb, line 12 def self.build(name, value, attributes) new(Cookie.new(name, value), attributes) end
new(cookie, attributes = Attribute::Set::EMPTY)
click to toggle source
Calls superclass method
# File lib/cookie/header.rb, line 16 def initialize(cookie, attributes = Attribute::Set::EMPTY) super end
Public Instance Methods
delete()
click to toggle source
# File lib/cookie/header.rb, line 44 def delete new(Empty.new(cookie.name), attributes.merge(Attribute::Expired)) end
http_only()
click to toggle source
# File lib/cookie/header.rb, line 40 def http_only with_attribute(Attribute::HttpOnly.instance) end
secure()
click to toggle source
# File lib/cookie/header.rb, line 36 def secure with_attribute(Attribute::Secure.instance) end
to_s()
click to toggle source
# File lib/cookie/header.rb, line 48 def to_s "#{cookie}#{attributes}" end
with_domain(domain)
click to toggle source
# File lib/cookie/header.rb, line 20 def with_domain(domain) with_attribute(Attribute::Domain.new(domain)) end
with_expires(time)
click to toggle source
# File lib/cookie/header.rb, line 32 def with_expires(time) with_attribute(Attribute::Expires.new(time)) end
with_max_age(seconds)
click to toggle source
# File lib/cookie/header.rb, line 28 def with_max_age(seconds) with_attribute(Attribute::MaxAge.new(seconds)) end
with_path(path)
click to toggle source
# File lib/cookie/header.rb, line 24 def with_path(path) with_attribute(Attribute::Path.new(path)) end
Private Instance Methods
new(cookie, attributes)
click to toggle source
# File lib/cookie/header.rb, line 59 def new(cookie, attributes) self.class.new(cookie, attributes) end
with_attribute(attribute)
click to toggle source
# File lib/cookie/header.rb, line 55 def with_attribute(attribute) new(cookie, attributes.merge(attribute)) end