Class: ActionDispatch::Cookies::SignedCookieJar
Overview
:nodoc:
Constant Summary
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
230 231 232 233 234 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 230 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)
256 257 258 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 256 def method_missing(method, *arguments, &block) @parent_jar.send(method, *arguments, &block) end |
Instance Method Details
- (Object) [](name)
236 237 238 239 240 241 242 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 236 def [](name) if = @parent_jar[name] @verifier.verify() end rescue ActiveSupport::MessageVerifier::InvalidSignature nil end |
- (Object) []=(key, options)
244 245 246 247 248 249 250 251 252 253 254 |
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 244 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 |