Class: Knjappserver::Session

Inherits:
Knj::Datarow
  • Object
show all
Defined in:
lib/include/class_session.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#edataObject (readonly)

Returns the value of attribute edata.



2
3
4
# File 'lib/include/class_session.rb', line 2

def edata
  @edata
end

#sess_dataObject

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

#flushObject



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