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.1'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce(string) ⇒ Object



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

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

Instance Method Details

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



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

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

#decrypt(box) ⇒ Object



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

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

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



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

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

#encrypt(box) ⇒ Object



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

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

#to_sObject



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

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