Merge pull request #19823 from sbhatore/doc_fix_1

[ci skip] Description inside Signed and Encrypted CookieJars added
This commit is contained in:
Rafael Mendonça França 2015-04-23 14:40:40 -03:00
commit d949460f9b
1 changed files with 8 additions and 0 deletions

View File

@ -454,12 +454,16 @@ module ActionDispatch
@verifier = ActiveSupport::MessageVerifier.new(secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) @verifier = ActiveSupport::MessageVerifier.new(secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer)
end end
# Returns the value of the cookie by +name+ if it is untampered,
# returns +nil+ otherwise or if no such cookie exists.
def [](name) def [](name)
if signed_message = @parent_jar[name] if signed_message = @parent_jar[name]
deserialize name, verify(signed_message) deserialize name, verify(signed_message)
end end
end end
# Signs and Sets the cookie named +name+. The second argument may be the cookie's
# value or a hash of options as documented above.
def []=(name, options) def []=(name, options)
if options.is_a?(Hash) if options.is_a?(Hash)
options.symbolize_keys! options.symbolize_keys!
@ -511,12 +515,16 @@ module ActionDispatch
@encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) @encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer)
end end
# Returns the value of the cookie by +name+ if it is untampered,
# returns +nil+ otherwise or if no such cookie exists.
def [](name) def [](name)
if encrypted_message = @parent_jar[name] if encrypted_message = @parent_jar[name]
deserialize name, decrypt_and_verify(encrypted_message) deserialize name, decrypt_and_verify(encrypted_message)
end end
end end
# Encrypts and Sets the cookie named +name+. The second argument may be the cookie's
# value or a hash of options as documented above.
def []=(name, options) def []=(name, options)
if options.is_a?(Hash) if options.is_a?(Hash)
options.symbolize_keys! options.symbolize_keys!