Class: Rubotnik::UserStore
- Inherits:
-
Object
- Object
- Rubotnik::UserStore
- Includes:
- Singleton
- Defined in:
- lib/rubotnik/user_store.rb
Overview
In-memory storage for users
Instance Attribute Summary collapse
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #add(user) ⇒ Object
- #find(id) ⇒ Object
- #find_or_create_user(id) ⇒ Object
-
#initialize ⇒ UserStore
constructor
A new instance of UserStore.
Constructor Details
#initialize ⇒ UserStore
Returns a new instance of UserStore.
8 9 10 |
# File 'lib/rubotnik/user_store.rb', line 8 def initialize @users = [] end |
Instance Attribute Details
#users ⇒ Object (readonly)
Returns the value of attribute users.
6 7 8 |
# File 'lib/rubotnik/user_store.rb', line 6 def users @users end |
Instance Method Details
#add(user) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubotnik/user_store.rb', line 16 def add(user) @users << user user = @users.last if user Rubotnik.logger.info "user #{user.inspect} added to store" Rubotnik.logger.info "we got #{@users.count} users: #{@users}" else Rubotnik.logger.info 'user not found in store yet' end user end |