class Rack::Session::XFile

Constants

DEFAULT_OPTIONS
File
SIDCharacters
VERSION

Public Class Methods

new(app, options = {}) click to toggle source
Calls superclass method
# File lib/rack/session/xfile.rb, line 20
def initialize(app, options = {})
  super
  @mutex       = Mutex.new
  @session_dir = default_options[:session_dir]
  @ua_filter   = default_options[:user_agent_filter]
  @sid_nbytes  = default_options[:sidbits] / 8
  setup_directories
  check_permissions
end

Public Instance Methods

delete_session(req, sid, options) click to toggle source
# File lib/rack/session/xfile.rb, line 47
def delete_session(req, sid, options)
  critical_section(req) do
    File.unlink(session_file(sid)) rescue nil
    generate_sid unless options[:drop]
  end
end
find_session(req, sid) click to toggle source
# File lib/rack/session/xfile.rb, line 36
def find_session(req, sid)
  return [nil, {}] if filter_request(req, sid)

  critical_section(req) do
    unless sid and session = read_session_file(sid)
      sid, session = generate_sid, {}
    end
    [sid, session]
  end
end
session_count() click to toggle source
# File lib/rack/session/xfile.rb, line 54
def session_count
  Dir[File.join(@session_dir, '?', '*')].count
end
write_session(req, sid, session, options) click to toggle source
# File lib/rack/session/xfile.rb, line 30
def write_session(req, sid, session, options)
  critical_section(req) do
    write_session_file(sid, session)
  end
end