Class: ActionDispatch::Cookies::AbstractCookieJar

Inherits:
Object
  • Object
show all
Includes:
ChainedCookieJars
Defined in:
actionpack/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.


481
482
483
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 481

def initialize(parent_jar)
  @parent_jar = parent_jar
end

Instance Method Details

#[](name) ⇒ Object


485
486
487
488
489
490
491
492
493
494
495
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 485

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) ⇒ Object


497
498
499
500
501
502
503
504
505
506
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 497

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

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