Class: SessionCleanup

Inherits:
Object show all
Defined in:
lib/rwd/rwd.rb

Instance Method Summary collapse

Constructor Details

#initialize(sessions, interval, timeout) ⇒ SessionCleanup

Returns a new instance of SessionCleanup.



1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
# File 'lib/rwd/rwd.rb', line 1097

def initialize(sessions, interval, timeout)
  every(interval) do
    sessions.delete_if do |id, session|
      time	= Time.now.to_i - session.lastaccess.to_i

      puts "Session %s deleted" % id	if time > timeout

      time > timeout
    end
  end
end