Class: RoadForest::Authorization::DefaultAuthenticationStore

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/authorization/default-authentication-store.rb

Instance Method Summary collapse

Constructor Details

#initializeDefaultAuthenticationStore

Returns a new instance of DefaultAuthenticationStore.



5
6
7
# File 'lib/roadforest/authorization/default-authentication-store.rb', line 5

def initialize
  @accounts = []
end

Instance Method Details

#add_account(user, password, token) ⇒ Object



18
19
20
# File 'lib/roadforest/authorization/default-authentication-store.rb', line 18

def (user, password, token)
  @accounts << [user, password, token]
end

#build_entity(account) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/roadforest/authorization/default-authentication-store.rb', line 9

def build_entity()
  return nil if .nil?
  AuthEntity.new.tap do |entity|
    entity.username = [0]
    entity.password = [1]
    entity.token = [2]
  end
end

#by_token(token) ⇒ Object



27
28
29
30
# File 'lib/roadforest/authorization/default-authentication-store.rb', line 27

def by_token(token)
   = @accounts.find{|| [2] == token }
  build_entity()
end

#by_username(username) ⇒ Object



22
23
24
25
# File 'lib/roadforest/authorization/default-authentication-store.rb', line 22

def by_username(username)
   = @accounts.find{|| [0] == username }
  build_entity()
end