Class: Cybertrain::SignedCookieJar

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/cookie_jar.rb

Overview

cookies.signed: values the client can read but not change.

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ String?

The value, or nil when the cookie is missing or its signature does not match.

Parameters:

  • name (String, Symbol)

Returns:

  • (String, nil)


328
329
330
# File 'cybertrain/cookie_jar.rb', line 328

def [](name)
  @jar.verified_cookie(name.to_s)
end

#[]=(name, value) ⇒ String

Parameters:

  • name (String, Symbol)
  • value (String, Hash)

Returns:

  • (String)


336
337
338
# File 'cybertrain/cookie_jar.rb', line 336

def []=(name, value)
  @jar.assign_cookie(name.to_s, value, CookieJar::SIGNED, @permanent)
end

#delete(name, path: "/") ⇒ String?

Returns the raw (signed) value it had.

Parameters:

  • name (String, Symbol)
  • path (String) (defaults to: "/")

Returns:

  • (String, nil) —

    the raw (signed) value it had



344
345
346
# File 'cybertrain/cookie_jar.rb', line 344

def delete(name, path: "/")
  @jar.delete(name, path: path)
end