Class: Mynatra::User

Inherits:
Object
  • Object
show all
Defined in:
lib/mynatra/mynatra.rb

Overview

Test class

Constant Summary collapse

@@Users =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/mynatra/mynatra.rb', line 6

def email
  @email
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/mynatra/mynatra.rb', line 6

def password
  @password
end

Class Method Details

.allObject



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_manyObject



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

#deleteObject



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