Class: Knjappserver::Session
- Inherits:
-
Knj::Datarow
- Object
- Knj::Datarow
- Knjappserver::Session
- Defined in:
- lib/include/class_session.rb
Instance Attribute Summary collapse
-
#edata ⇒ Object
readonly
Returns the value of attribute edata.
-
#sess_data ⇒ Object
Returns the value of attribute sess_data.
Class Method Summary collapse
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(*args, &block) ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(*args, &block) ⇒ Session
Returns a new instance of Session.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/include/class_session.rb', line 5 def initialize(*args, &block) @edata = {} super(*args, &block) if self[:sess_data].to_s.length > 0 begin @sess_data = Marshal.load(Base64.decode64(self[:sess_data])) rescue ArgumentError @sess_data = {} end else @sess_data = {} end end |
Instance Attribute Details
#edata ⇒ Object (readonly)
Returns the value of attribute edata.
2 3 4 |
# File 'lib/include/class_session.rb', line 2 def edata @edata end |
#sess_data ⇒ Object
Returns the value of attribute sess_data.
3 4 5 |
# File 'lib/include/class_session.rb', line 3 def sess_data @sess_data end |
Class Method Details
.add(d) ⇒ Object
20 21 22 23 |
# File 'lib/include/class_session.rb', line 20 def self.add(d) d.data[:date_added] = Time.now if !d.data[:date_added] d.data[:date_lastused] = Time.now if !d.data[:date_lastused] end |
Instance Method Details
#flush ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/include/class_session.rb', line 25 def flush flush_data = Base64.encode64(Marshal.dump(@sess_data)) if self[:sess_data] != flush_data self.update( :sess_data => flush_data, :date_lastused => Time.now ) end end |