123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Cookies::AbstractCookieJar

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/middleware/cookies.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

ChainedCookieJars - Included

#encrypted

Returns a jar that’ll automatically encrypt cookie values before sending them to the client and will decrypt them for read.

#permanent

Returns a jar that’ll automatically set the assigned cookies to have an expiration date 20 years from now.

#signed

Returns a jar that’ll automatically generate a signed representation of cookie value and verify it when reading from the cookie again.

#signed_or_encrypted

Returns the signed or encrypted jar, preferring encrypted if secret_key_base is set.

#encrypted_cookie_cipher, #signed_cookie_digest

Constructor Details

.new(parent_jar) ⇒ AbstractCookieJar

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 509

def initialize(parent_jar)
  @parent_jar = parent_jar
end

Instance Method Details

#[](name)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 513

def [](name)
  if data = @parent_jar[name.to_s]
    result = parse(name, data, purpose: "cookie.#{name}")

    if result.nil?
      parse(name, data)
    else
      result
    end
  end
end

#[]=(name, options)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 525

def []=(name, options)
  if options.is_a?(Hash)
    options.symbolize_keys!
  else
    options = { value: options }
  end

  commit(name, options)
  @parent_jar[name] = options
end

#commit(name, options) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 555

def commit(name, options); end

#expiry_options(options) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 540

def expiry_options(options)
  if options[:expires].respond_to?(:from_now)
    { expires_in: options[:expires] }
  else
    { expires_at: options[:expires] }
  end
end

#parse(name, data, purpose: nil) (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 554

def parse(name, data, purpose: nil); data; end

#request (protected)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 537

def request; @parent_jar.request; end