Class: Mynatra::User
- Inherits:
-
Object
- Object
- Mynatra::User
- Defined in:
- lib/mynatra/mynatra.rb
Overview
Test class
Constant Summary collapse
- @@Users =
[]
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/mynatra/mynatra.rb', line 6 def email @email end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/mynatra/mynatra.rb', line 6 def password @password end |
Class Method Details
.all ⇒ Object
40 41 42 |
# File 'lib/mynatra/mynatra.rb', line 40 def self.all @@Users end |
.create(email) ⇒ Object
18 19 20 21 22 |
# File 'lib/mynatra/mynatra.rb', line 18 def self.create(email) user = User.new user.email = email @@Users << user end |
.create_many ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/mynatra/mynatra.rb', line 32 def self.create_many @@Users = (1..25).map do |num| user = User.new user.email = "user#{num}@example.com" user end end |
.find_by_email(email) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mynatra/mynatra.rb', line 24 def self.find_by_email(email) @@Users.each do |user| if user.email == email return user end end end |
Instance Method Details
#delete ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mynatra/mynatra.rb', line 10 def delete @@Users.each_with_index do |user, index| if self.email == user.email @@Users.delete_at(index) end end end |