Class: Rubylet::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylet/session.rb

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ Session

Returns a new instance of Session.



3
4
5
# File 'lib/rubylet/session.rb', line 3

def initialize(req)
  @javaSession = req.getSession
end

Instance Method Details

#clearObject



23
24
25
# File 'lib/rubylet/session.rb', line 23

def clear
  @javaSession.getAttributeNames.each {|key| delete(key) }
end

#delete(key) ⇒ Object



19
20
21
# File 'lib/rubylet/session.rb', line 19

def delete(key)
  @javaSession.removeAttribute(key)
end

#fetch(key, default = nil) ⇒ Object Also known as: []



13
14
15
# File 'lib/rubylet/session.rb', line 13

def fetch(key, default = nil)
  @javaSession.getAttribute(key) || default
end

#store(key, value) ⇒ Object Also known as: []=



7
8
9
# File 'lib/rubylet/session.rb', line 7

def store(key, value)
  @javaSession.setAttribute(key, value)
end

#to_hashObject



27
28
29
30
31
# File 'lib/rubylet/session.rb', line 27

def to_hash
  hash = {}
  @javaSession.getAttributeNames.each {|key| hash[key] = @javaSession.getAttribute(key) }
  hash
end