Sha256: d05c4a8c6d331a76095054679492f1efa3cdc6f84d226ad1487a70ab80d95387

Contents?: true

Size: 912 Bytes

Versions: 12

Compression:

Stored size: 912 Bytes

Contents

class Kiss
  class Login < Hash
    def initialize(session)
      @_session = session
      @_session['login'] ||= {}
      
      # check if login expired
      if expired?
        # login expired
        @_session['login'] = {}
      end
      
      @_persist_data = @_session['login']
      self.merge!(@_persist_data)
    end
    
    def expired?
      @_session['login']['expires_at'] && session['login']['expires_at'] < Time.now
    end
    
    def persist(data = {})
      @_persist_data.merge!(data)
      self.merge!(data)
    end
    
    def expires_at(time)
      persist(:expires_at => time)
    end
    def expires_at=(seconds)
      expires_at(seconds)
    end
    
    def expires_in(seconds)
      persist(:expires_at => Time.now + seconds)
    end
    def expires_in=(seconds)
      expires_in(seconds)
    end
    
    def clear
      @_session['login'] = {}
      super()
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kiss-1.8.7 lib/kiss/login.rb
kiss-1.8.6 lib/kiss/login.rb
kiss-1.8.5 lib/kiss/login.rb
kiss-1.8.4 lib/kiss/login.rb
kiss-1.8.3 lib/kiss/login.rb
kiss-1.8.2 lib/kiss/login.rb
kiss-1.8.1 lib/kiss/login.rb
kiss-1.8 lib/kiss/login.rb
kiss-1.7.4 lib/kiss/login.rb
kiss-1.7.2 lib/kiss/login.rb
kiss-1.7.1 lib/kiss/login.rb
kiss-1.7 lib/kiss/login.rb