Sha256: 9d72ecb5c00db83b6daa3d12a43e6309107544aad569e55f938f28d5596f5961

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

module Resty
  class  AbstractSession

    attr_accessor :permissions, :user, :idle_session_timeout

    def self.create(login, password)
      self.do_create(authenticate(login, password))
    end
      
    def self.create_remote(login, password)
      self.do_create(authenticate_remote(login, password))
    end
      
    private
    def self.do_create(user)
      result = new
    
      if user.valid?
        result.user = user
      else
        result.log = user.to_log # error message
      end
      result
    end

    public

    def log=(msg)
      @log = msg
    end

    def to_log
      if @log
        @log
      else
        "Session(user-id: #{user.id}, idle-session-timeout: #{idle_session_timeout})"
      end
    end

    def valid?
      @log.nil?
    end
    
    def attributes
      {'idle_session_timeout' => idle_session_timeout, 'permissions' => permissions, 'user' => user}
    end
    
    protected

    def self.authenticate(login, password)
      raise "not implemented"
    end

    def self.authenticate_remote(login, password)
      raise "not implemented"
    end
  end
end
  

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ixtlan-guard-0.9.0 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.8.3 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.8.2 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.8.1 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.8.0 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.7.2 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.7.0 lib/ixtlan/guard/abstract_session.rb~
ixtlan-guard-0.6.1 lib/ixtlan/guard/abstract_session.rb~