Class: ActionDispatch::Cookies::SignedCookieJar
Overview
:nodoc:
Constant Summary
- MAX_COOKIE_SIZE =
4096- SECRET_MIN_LENGTH =
Cookies can typically store 4096 bytes. Characters
30
Constants inherited from CookieJar
Instance Method Summary (collapse)
- - (Object) [](name)
- - (Object) []=(key, options)
-
- (SignedCookieJar) initialize(parent_jar, secret)
constructor
A new instance of SignedCookieJar.
- - (Object) method_missing(method, *arguments, &block)
Methods inherited from CookieJar
build, #clear, #delete, #each, #handle_options, #key?, #permanent, #recycle!, #signed, #update, #write
Methods included from Enumerable
#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum
Constructor Details
- (SignedCookieJar) initialize(parent_jar, secret)
A new instance of SignedCookieJar
281 282 283 284 285 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 281 def initialize(parent_jar, secret) ensure_secret_secure(secret) @parent_jar = parent_jar @verifier = ActiveSupport::MessageVerifier.new(secret) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *arguments, &block)
307 308 309 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 307 def method_missing(method, *arguments, &block) @parent_jar.send(method, *arguments, &block) end |
Instance Method Details
- (Object) [](name)
287 288 289 290 291 292 293 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 287 def [](name) if = @parent_jar[name] @verifier.verify() end rescue ActiveSupport::MessageVerifier::InvalidSignature nil end |
- (Object) []=(key, options)
295 296 297 298 299 300 301 302 303 304 305 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 295 def []=(key, ) 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[key] = end |