Class: RoadForest::Authorization::DefaultAuthenticationStore

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

Instance Method Summary collapse

Constructor Details

#initializeDefaultAuthenticationStore

Returns a new instance of DefaultAuthenticationStore.



189
190
191
# File 'lib/roadforest/authorization.rb', line 189

def initialize
  @accounts = []
end

Instance Method Details

#add_account(user, password, token) ⇒ Object



202
203
204
# File 'lib/roadforest/authorization.rb', line 202

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

#build_entity(account) ⇒ Object



193
194
195
196
197
198
199
200
# File 'lib/roadforest/authorization.rb', line 193

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



211
212
213
214
# File 'lib/roadforest/authorization.rb', line 211

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

#by_username(username) ⇒ Object



206
207
208
209
# File 'lib/roadforest/authorization.rb', line 206

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