class RoadForest::Authorization::DefaultAuthenticationStore
Public Class Methods
new()
click to toggle source
# File lib/roadforest/authorization/default-authentication-store.rb, line 5 def initialize @accounts = [] end
Public Instance Methods
add_account(user, password, token)
click to toggle source
# File lib/roadforest/authorization/default-authentication-store.rb, line 18 def add_account(user, password, token) @accounts << [user, password, token] end
build_entity(account)
click to toggle source
# File lib/roadforest/authorization/default-authentication-store.rb, line 9 def build_entity(account) return nil if account.nil? AuthEntity.new.tap do |entity| entity.username = account[0] entity.password = account[1] entity.token = account[2] end end
by_token(token)
click to toggle source
# File lib/roadforest/authorization/default-authentication-store.rb, line 27 def by_token(token) account = @accounts.find{|account| account[2] == token } build_entity(account) end
by_username(username)
click to toggle source
# File lib/roadforest/authorization/default-authentication-store.rb, line 22 def by_username(username) account = @accounts.find{|account| account[0] == username } build_entity(account) end