Class: ActionDispatch::Cookies::PermanentCookieJar

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

Overview

:nodoc:

Constant Summary

Constants inherited from CookieJar

CookieJar::DOMAIN_REGEXP

Instance Attribute Summary

Attributes inherited from CookieJar

#closed

Instance Method Summary collapse

Methods inherited from CookieJar

#[], build, #close!, #delete, #each, #handle_options, #key?, #permanent, #update, #write

Methods included from Enumerable

#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum

Constructor Details

#initialize(parent_jar, secret) ⇒ PermanentCookieJar

Returns a new instance of PermanentCookieJar.



243
244
245
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 243

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



263
264
265
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 263

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

Instance Method Details

#[]=(key, options) ⇒ Object

Raises:



247
248
249
250
251
252
253
254
255
256
257
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 247

def []=(key, options)
  raise ClosedError, :cookies if closed?
  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



259
260
261
# File 'actionpack/lib/action_dispatch/middleware/cookies.rb', line 259

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