Class: RoadForest::Authorization::AuthEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/authorization/auth-entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuthEntity

Returns a new instance of AuthEntity.



4
5
6
# File 'lib/roadforest/authorization/auth-entity.rb', line 4

def initialize
  @authenticated = false
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/roadforest/authorization/auth-entity.rb', line 7

def password
  @password
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/roadforest/authorization/auth-entity.rb', line 7

def token
  @token
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/roadforest/authorization/auth-entity.rb', line 7

def username
  @username
end

Instance Method Details

#authenticate!Object



21
22
23
# File 'lib/roadforest/authorization/auth-entity.rb', line 21

def authenticate!
  @authenticated = true
end

#authenticate_by_password(password) ⇒ Object



13
14
15
# File 'lib/roadforest/authorization/auth-entity.rb', line 13

def authenticate_by_password(password)
  @authenticated = (!password.nil? and password == @password)
end

#authenticate_by_token(token) ⇒ Object



17
18
19
# File 'lib/roadforest/authorization/auth-entity.rb', line 17

def authenticate_by_token(token)
  @authenticated = (!token.nil? and token == @token)
end

#authenticated?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/roadforest/authorization/auth-entity.rb', line 9

def authenticated?
  !!@authenticated
end