Class: Cookie

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/cookie.rb,
lib/cookie/header.rb,
lib/cookie/version.rb,
lib/cookie/registry.rb,
lib/cookie/header/attribute.rb

Overview

Models an HTTP Cookie

Direct Known Subclasses

Empty

Defined Under Namespace

Modules: Decoder, Encoder Classes: Empty, Header, Registry

Constant Summary collapse

EMPTY_ARRAY =

An empty frozen array

[].freeze
EMPTY_HASH =

An empty frozen hash

{}.freeze
EMPTY_STRING =

An empty frozen string

''.freeze
NAME_VALUE_SEPARATOR =

Separates the cookie name from its value

'='.freeze
'; '.freeze
DOUBLE_COLON =

Separates ruby class names in a FQN

'::'.freeze
Error =

Cookie error base class

Class.new(StandardError)
VERSION =

Gem version

'0.0.4'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce(string) ⇒ Object



55
56
57
# File 'lib/cookie.rb', line 55

def self.coerce(string)
  new(*string.split(NAME_VALUE_SEPARATOR, 2))
end

Instance Method Details

#decode(decoder = Decoder::Base64) ⇒ Object



63
64
65
# File 'lib/cookie.rb', line 63

def decode(decoder = Decoder::Base64)
  new(decoder.call(value))
end

#decrypt(box) ⇒ Object



71
72
73
# File 'lib/cookie.rb', line 71

def decrypt(box)
  new(box.decrypt(value))
end

#encode(encoder = Encoder::Base64) ⇒ Object



59
60
61
# File 'lib/cookie.rb', line 59

def encode(encoder = Encoder::Base64)
  new(encoder.call(value))
end

#encrypt(box) ⇒ Object



67
68
69
# File 'lib/cookie.rb', line 67

def encrypt(box)
  new(box.encrypt(value))
end

#to_sObject



75
76
77
# File 'lib/cookie.rb', line 75

def to_s
  "#{name}=#{value}"
end