Class: Rubylet::Session
- Inherits:
-
Object
- Object
- Rubylet::Session
- Defined in:
- lib/rubylet/session.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #fetch(key, default = nil) ⇒ Object (also: #[])
-
#initialize(req) ⇒ Session
constructor
A new instance of Session.
- #store(key, value) ⇒ Object (also: #[]=)
- #to_hash ⇒ Object
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
#clear ⇒ Object
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_hash ⇒ Object
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 |