Class: RoadForest::Authorization::DefaultAuthenticationStore
- Inherits:
-
Object
- Object
- RoadForest::Authorization::DefaultAuthenticationStore
- Defined in:
- lib/roadforest/authorization/default-authentication-store.rb
Instance Method Summary collapse
- #add_account(user, password, token) ⇒ Object
- #build_entity(account) ⇒ Object
- #by_token(token) ⇒ Object
- #by_username(username) ⇒ Object
-
#initialize ⇒ DefaultAuthenticationStore
constructor
A new instance of DefaultAuthenticationStore.
Constructor Details
#initialize ⇒ DefaultAuthenticationStore
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 add_account(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(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) ⇒ Object
27 28 29 30 |
# 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) ⇒ Object
22 23 24 25 |
# 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 |