Class: ActionDispatch::Cookies::SignedCookieJar
- Inherits:
-
Object
- Object
- ActionDispatch::Cookies::SignedCookieJar
- Includes:
- ChainedCookieJars
- Defined in:
- lib/action_dispatch/middleware/cookies.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, options) ⇒ Object
-
#initialize(parent_jar, key_generator, options = {}) ⇒ SignedCookieJar
constructor
A new instance of SignedCookieJar.
Methods included from ChainedCookieJars
#encrypted, #permanent, #signed, #signed_or_encrypted
Constructor Details
#initialize(parent_jar, key_generator, options = {}) ⇒ SignedCookieJar
Returns a new instance of SignedCookieJar.
378 379 380 381 382 383 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 378 def initialize(parent_jar, key_generator, = {}) @parent_jar = parent_jar @options = secret = key_generator.generate_key(@options[:signed_cookie_salt]) @verifier = ActiveSupport::MessageVerifier.new(secret) end |
Instance Method Details
#[](name) ⇒ Object
385 386 387 388 389 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 385 def [](name) if = @parent_jar[name] verify() end end |
#[]=(name, options) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/action_dispatch/middleware/cookies.rb', line 391 def []=(name, ) if .is_a?(Hash) .symbolize_keys! [:value] = @verifier.generate([:value]) else = { :value => @verifier.generate() } end raise CookieOverflow if [:value].size > MAX_COOKIE_SIZE @parent_jar[name] = end |