Class: CGI::Session::PStore

Inherits:
Object show all
Defined in:
lib/action_controller/cgi_ext/pstore_performance_fix.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(session, option = {}) ⇒ PStore

Returns a new instance of PStore.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/action_controller/cgi_ext/pstore_performance_fix.rb', line 10

def initialize(session, option={})
  dir = option['tmpdir'] || Dir::tmpdir
  prefix = option['prefix'] || ''
  id = session.session_id
  md5 = Digest::MD5.hexdigest(id)[0,16]
  path = dir+"/"+prefix+md5
  path.untaint
  if File::exist?(path)
    @hash = nil
  else
    unless session.new_session
      raise CGI::Session::NoSession, "uninitialized session"
    end
    @hash = {}
  end
  @p = ::PStore.new(path)
  @p.transaction do |p|
    File.chmod(0600, p.path)
  end
end