Class: TestyCookie::Proxy

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/testy_cookie/proxy.rb

Overview

Proxy for propagating cookie changes to ‘Rack::Test::CookieJar`

Instance Method Summary collapse

Constructor Details

#initialize(cookies, raw_cookies, parent) ⇒ Proxy

Returns a new instance of Proxy.

Parameters:

  • cookies (ActionDispatch::Cookies::CookieJar)

    the cookie jar to delegate to

  • raw_cookies (Rack::Test::CookieJar)

    the cookies to propagate changes to

  • parent (Proxy, nil)

    the parent proxy to chain cookie operations



7
8
9
10
11
# File 'lib/testy_cookie/proxy.rb', line 7

def initialize(cookies, raw_cookies, parent)
  super(cookies)
  @parent = parent
  @raw_cookies = raw_cookies
end

Instance Method Details

#[]=(key, value) ⇒ Object

Parameters:

  • key (String)

    the cookie key

  • value (String)

    the cookie value



15
16
17
18
# File 'lib/testy_cookie/proxy.rb', line 15

def []=(key, value)
  super
  assign(key)
end

#encryptedProxy

Returns proxy to the encrypted cookie jar.

Returns:

  • (Proxy)

    proxy to the encrypted cookie jar



21
22
23
# File 'lib/testy_cookie/proxy.rb', line 21

def encrypted
  self.class.new(__getobj__.encrypted, @raw_cookies, self)
end

#permanentProxy

Returns proxy to the permanent cookie jar.

Returns:

  • (Proxy)

    proxy to the permanent cookie jar



26
27
28
# File 'lib/testy_cookie/proxy.rb', line 26

def permanent
  self.class.new(__getobj__.permanent, @raw_cookies, self)
end

#signedProxy

Returns proxy the signed cookie jar.

Returns:

  • (Proxy)

    proxy the signed cookie jar



31
32
33
# File 'lib/testy_cookie/proxy.rb', line 31

def signed
  self.class.new(__getobj__.signed, @raw_cookies, self)
end