Class: ActionDispatch::Cookies::PermanentCookieJar

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, key_generator, options = {}) ⇒ PermanentCookieJar

Returns a new instance of PermanentCookieJar.



364
365
366
367
368
# File 'lib/action_dispatch/middleware/cookies.rb', line 364

def initialize(parent_jar, key_generator, options = {})
  @parent_jar = parent_jar
  @key_generator = key_generator
  @options = options
end

Instance Method Details

#[](name) ⇒ Object



370
371
372
# File 'lib/action_dispatch/middleware/cookies.rb', line 370

def [](name)
  @parent_jar[name.to_s]
end

#[]=(name, options) ⇒ Object



374
375
376
377
378
379
380
381
382
383
# File 'lib/action_dispatch/middleware/cookies.rb', line 374

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

  options[:expires] = 20.years.from_now
  @parent_jar[name] = options
end