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, #delete, #handle_options, #permanent, #signed, #write
Methods inherited from Hash
#as_json, #assert_valid_keys, #deep_merge, #deep_merge!, #diff, #encode_json, #except, #except!, #extract!, #extractable_options?, from_xml, #reverse_merge, #reverse_merge!, #slice, #slice!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!, #to_param, #to_xml, #with_indifferent_access
Constructor Details
- (SignedCookieJar) initialize(parent_jar, secret)
A new instance of SignedCookieJar
238 239 240 241 242 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 238 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)
264 265 266 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 264 def method_missing(method, *arguments, &block) @parent_jar.send(method, *arguments, &block) end |
Instance Method Details
- (Object) [](name)
244 245 246 247 248 249 250 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 244 def [](name) if = @parent_jar[name] @verifier.verify() end rescue ActiveSupport::MessageVerifier::InvalidSignature nil end |
- (Object) []=(key, options)
252 253 254 255 256 257 258 259 260 261 262 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 252 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 |