Class: ActionDispatch::Cookies::PermanentCookieJar

Inherits:
CookieJar
  • Object
show all
Defined in:
lib/action_dispatch/middleware/cookies.rb

Overview

:nodoc:

Constant Summary

Constants inherited from CookieJar

CookieJar::DOMAIN_REGEXP

Instance Method Summary collapse

Methods inherited from CookieJar

#[], build, #delete, #handle_options, #permanent, #write

Constructor Details

#initialize(parent_jar, secret) ⇒ PermanentCookieJar

Returns a new instance of PermanentCookieJar.


217
218
219
# File 'lib/action_dispatch/middleware/cookies.rb', line 217

def initialize(parent_jar, secret)
  @parent_jar, @secret = parent_jar, secret
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object


236
237
238
# File 'lib/action_dispatch/middleware/cookies.rb', line 236

def method_missing(method, *arguments, &block)
  @parent_jar.send(method, *arguments, &block)
end

Instance Method Details

#[]=(key, options) ⇒ Object


221
222
223
224
225
226
227
228
229
230
# File 'lib/action_dispatch/middleware/cookies.rb', line 221

def []=(key, options)
  if options.is_a?(Hash)
    options.symbolize_keys!
  else
    options = { :value => options }
  end

  options[:expires] = 20.years.from_now
  @parent_jar[key] = options
end

#signedObject


232
233
234
# File 'lib/action_dispatch/middleware/cookies.rb', line 232

def signed
  @signed ||= SignedCookieJar.new(self, @secret)
end