Class: Rack::Session::File::Marshal::Transaction

Inherits:
Abstract::Transaction show all
Defined in:
lib/rack/session/file/marshal.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



35
36
37
38
39
40
41
42
43
# File 'lib/rack/session/file/marshal.rb', line 35

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

#expire_sessions(time) ⇒ Object



45
46
47
# File 'lib/rack/session/file/marshal.rb', line 45

def expire_sessions(time)
  # TODO
end

#load_session(sid) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rack/session/file/marshal.rb', line 21

def load_session(sid)
  begin
    open_session_file(sid, 'r') do |file|
      return ::Marshal.load(file)
    end
  rescue InvalidSessionIDError
    return nil
  rescue Errno::ENOENT
    return nil
  rescue TypeError
    return nil
  end
end

#store_session(sid, data) ⇒ Object



15
16
17
18
19
# File 'lib/rack/session/file/marshal.rb', line 15

def store_session(sid, data)
  open_session_file(sid, 'w') do |file|
    ::Marshal.dump(data, file)
  end
end