Sha256: 4432bd8a7114fb9c0eca65b7eeebd99db981189d04ec6aedc8dcb212340f46d0

Contents?: true

Size: 853 Bytes

Versions: 23

Compression:

Stored size: 853 Bytes

Contents

class Hayabusa::Models::Session < Knj::Datarow
  attr_reader :edata
  attr_accessor :sess_data
  
  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]))
        raise "The session-data could not be loaded." if !@sess_data
      rescue ArgumentError
        @sess_data = {}
      end
    else
      @sess_data = {}
    end
  end
  
  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
  
  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
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
hayabusa-0.0.28 lib/models/session.rb
hayabusa-0.0.25 lib/models/session.rb
hayabusa-0.0.24 lib/models/session.rb
hayabusa-0.0.23 lib/models/session.rb
hayabusa-0.0.22 lib/models/session.rb
hayabusa-0.0.20 lib/models/session.rb
hayabusa-0.0.19 lib/models/session.rb
hayabusa-0.0.18 lib/models/session.rb
hayabusa-0.0.17 lib/models/session.rb
hayabusa-0.0.16 lib/models/session.rb
hayabusa-0.0.15 lib/models/session.rb
hayabusa-0.0.14 lib/models/session.rb
hayabusa-0.0.13 lib/models/session.rb
hayabusa-0.0.12 lib/models/session.rb
hayabusa-0.0.11 lib/models/session.rb
hayabusa-0.0.10 lib/models/session.rb
hayabusa-0.0.9 lib/models/session.rb
hayabusa-0.0.8 lib/models/session.rb
hayabusa-0.0.6 lib/models/session.rb
hayabusa-0.0.5 lib/models/session.rb