Class: Rack::Session::File::PStore::Transaction

Inherits:
Abstract::Transaction show all
Defined in:
lib/rack/session/file/pstore.rb

Instance Method Summary collapse

Methods inherited from Abstract::Transaction

#find_session, #initialize, #save_session, #with_lock

Constructor Details

This class inherits a constructor from Rack::Session::File::Abstract::Transaction

Instance Method Details

#delete_session(sid) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/rack/session/file/pstore.rb', line 44

def delete_session(sid)
  begin
    filename = store_for_sid(sid).path
    if ::File.exists?(filename)
      ::File.unlink(filename)
    end
  rescue InvalidSessionIDError
  end
end

#expire_sessions(time) ⇒ Object



54
55
56
# File 'lib/rack/session/file/pstore.rb', line 54

def expire_sessions(time)
  # TODO
end

#load_session(sid) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rack/session/file/pstore.rb', line 26

def load_session(sid)
  ensure_storage_accessible()

  data = {}
  begin
    store_for_sid(sid).transaction(true) do |db|
      db.roots.each do |key|
        data[key] = db[key]
      end
    end
  rescue InvalidSessionIDError
    return nil
  rescue TypeError
    return nil
  end
  return data
end

#store_session(sid, data) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rack/session/file/pstore.rb', line 16

def store_session(sid, data)
  ensure_storage_accessible()

  store_for_sid(sid).transaction do |db|
    data.keys.each do |key|
      db[key] = data[key]
    end
  end
end