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.
161 162 163 164 165 166 167 168 |
# File 'lib/action_controller/cookies.rb', line 161 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
187 188 189 |
# File 'lib/action_controller/cookies.rb', line 187 def method_missing(method, *arguments, &block) @parent_jar.send(method, *arguments, &block) end |
Instance Method Details
#[](name) ⇒ Object
170 171 172 173 174 |
# File 'lib/action_controller/cookies.rb', line 170 def [](name) if value = @parent_jar[name] @verifier.verify(value) end end |
#[]=(key, options) ⇒ Object
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/action_controller/cookies.rb', line 176 def []=(key, ) if .is_a?(Hash) .symbolize_keys! [:value] = @verifier.generate([:value]) else = { :value => @verifier.generate() } end @parent_jar[key] = end |