Class: ActionDispatch::Cookies::AbstractCookieJar

Inherits:
Object
  • Object
show all
Includes:
ChainedCookieJars
Defined in:
lib/action_dispatch/middleware/cookies.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from ChainedCookieJars

#encrypted, #permanent, #signed, #signed_or_encrypted

Constructor Details

#initialize(parent_jar) ⇒ AbstractCookieJar

Returns a new instance of AbstractCookieJar.



455
456
457
# File 'lib/action_dispatch/middleware/cookies.rb', line 455

def initialize(parent_jar)
  @parent_jar = parent_jar
end

Instance Method Details

#[](name) ⇒ Object



459
460
461
462
463
# File 'lib/action_dispatch/middleware/cookies.rb', line 459

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

#[]=(name, options) ⇒ Object



465
466
467
468
469
470
471
472
473
474
# File 'lib/action_dispatch/middleware/cookies.rb', line 465

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

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