Class: RoadForest::Authorization::DefaultAuthenticationStore
- Inherits:
-
Object
- Object
- RoadForest::Authorization::DefaultAuthenticationStore
- Defined in:
- lib/roadforest/authorization.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.
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 add_account(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(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
211 212 213 214 |
# File 'lib/roadforest/authorization.rb', line 211 def by_token(token) account = @accounts.find{|account| account[2] == token } build_entity(account) end |
#by_username(username) ⇒ Object
206 207 208 209 |
# File 'lib/roadforest/authorization.rb', line 206 def by_username(username) account = @accounts.find{|account| account[0] == username } build_entity(account) end |