Class: ActionController::SignedCookieJar
- Defined in:
- lib/action_controller/cookies.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from CookieJar
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(key, options) ⇒ Object
-
#initialize(parent_jar) ⇒ SignedCookieJar
constructor
A new instance of SignedCookieJar.
- #method_missing(method, *arguments, &block) ⇒ Object
Methods inherited from CookieJar
Constructor Details
#initialize(parent_jar) ⇒ SignedCookieJar
Returns a new instance of SignedCookieJar.
167 168 169 170 171 172 173 174 |
# File 'lib/action_controller/cookies.rb', line 167 def initialize(parent_jar) unless parent_jar.controller.class. raise "You must set ActionController::Base.cookie_verifier_secret to use signed cookies" end @parent_jar = parent_jar @verifier = ActiveSupport::MessageVerifier.new(@parent_jar.controller.class.) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
193 194 195 |
# File 'lib/action_controller/cookies.rb', line 193 def method_missing(method, *arguments, &block) @parent_jar.send(method, *arguments, &block) end |
Instance Method Details
#[](name) ⇒ Object
176 177 178 179 180 |
# File 'lib/action_controller/cookies.rb', line 176 def [](name) if value = @parent_jar[name] @verifier.verify(value) end end |
#[]=(key, options) ⇒ Object
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/action_controller/cookies.rb', line 182 def []=(key, ) if .is_a?(Hash) .symbolize_keys! [:value] = @verifier.generate([:value]) else = { :value => @verifier.generate() } end @parent_jar[key] = end |