class ActionDispatch::Cookies::CookieJar

:nodoc:

def self.build(request)

def self.build(request)
  env = request.env
  key_generator = env[GENERATOR_KEY]
  options = options_for_env env
  host = request.host
  secure = request.ssl?
  new(key_generator, host, secure, options).tap do |hash|
    hash.update(request.cookies)
  end
end

def self.options_for_env(env) #:nodoc:

:nodoc:
def self.options_for_env(env) #:nodoc:
  { signed_cookie_salt: env[SIGNED_COOKIE_SALT] || '',
    encrypted_cookie_salt: env[ENCRYPTED_COOKIE_SALT] || '',
    encrypted_signed_cookie_salt: env[ENCRYPTED_SIGNED_COOKIE_SALT] || '',
    secret_token: env[SECRET_TOKEN],
    secret_key_base: env[SECRET_KEY_BASE],
    upgrade_legacy_signed_cookies: env[SECRET_TOKEN].present? && env[SECRET_KEY_BASE].present?
  }
end

def [](name)

Returns the value of the cookie by +name+, or +nil+ if no such cookie exists.
def [](name)
  @cookies[name.to_s]
end

def []=(name, options)

value, or a hash of options as documented above.
Sets the cookie named +name+. The second argument may be the very cookie
def []=(name, options)
  if options.is_a?(Hash)
    options.symbolize_keys!
    value = options[:value]
  else
    value = options
    options = { :value => value }
  end
  handle_options(options)
  if @cookies[name.to_s] != value or options[:expires]
    @cookies[name.to_s] = value
    @set_cookies[name.to_s] = options
    @delete_cookies.delete(name.to_s)
  end
  value
end

def clear(options = {})

Removes all cookies on the client machine by calling delete for each cookie
def clear(options = {})
  @cookies.each_key{ |k| delete(k, options) }
end

def delete(name, options = {})

an options hash to delete cookies with extra data such as a :path.
and the expiration date in the past. Like []=, you can pass in
Removes the cookie on the client machine by setting the value to an empty string
def delete(name, options = {})
  return unless @cookies.has_key? name.to_s
  options.symbolize_keys!
  handle_options(options)
  value = @cookies.delete(name.to_s)
  @delete_cookies[name.to_s] = options
  value
end

def deleted?(name, options = {})

deletion applies to a specific :path, :domain etc.
Like []=, you can pass in an options hash to test if a
Whether the given cookie is to be deleted by this CookieJar.
def deleted?(name, options = {})
  options.symbolize_keys!
  handle_options(options)
  @delete_cookies[name.to_s] == options
end

def each(&block)

def each(&block)
  @cookies.each(&block)
end

def fetch(name, *args, &block)

def fetch(name, *args, &block)
  @cookies.fetch(name.to_s, *args, &block)
end

def handle_options(options) #:nodoc:

:nodoc:
def handle_options(options) #:nodoc:
  options[:path] ||= "/"
  if options[:domain] == :all
    # if there is a provided tld length then we use it otherwise default domain regexp
    domain_regexp = options[:tld_length] ? /([^.]+\.?){#{options[:tld_length]}}$/ : DOMAIN_REGEXP
    # if host is not ip and matches domain regexp
    # (ip confirms to domain regexp so we explicitly check for ip)
    options[:domain] = if (@host !~ /^[\d.]+$/) && (@host =~ domain_regexp)
      ".#{$&}"
    end
  elsif options[:domain].is_a? Array
    # if host matches one of the supplied domains without a dot in front of it
    options[:domain] = options[:domain].find {|domain| @host.include? domain.sub(/^\./, '') }
  end
end

def initialize(key_generator, host = nil, secure = false, options = {})

def initialize(key_generator, host = nil, secure = false, options = {})
  @key_generator = key_generator
  @set_cookies = {}
  @delete_cookies = {}
  @host = host
  @secure = secure
  @options = options
  @cookies = {}
end

def key?(name)

def key?(name)
  @cookies.key?(name.to_s)
end

def recycle! #:nodoc:

:nodoc:
def recycle! #:nodoc:
  @set_cookies.clear
  @delete_cookies.clear
end

def update(other_hash)

def update(other_hash)
  @cookies.update other_hash.stringify_keys
  self
end

def write(headers)

def write(headers)
  @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) if write_cookie?(v) }
  @delete_cookies.each { |k, v| ::Rack::Utils.delete_cookie_header!(headers, k, v) }
end

def write_cookie?(cookie)

def write_cookie?(cookie)
  @secure || !cookie[:secure] || always_write_cookie
end