Class: User
- Inherits:
-
RedisModel
- Object
- RedisModel
- User
- Includes:
- BCrypt
- Defined in:
- app/models/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#password_digest ⇒ Object
Returns the value of attribute password_digest.
Instance Method Summary collapse
- #authenticate(given_password) ⇒ Object
- #password ⇒ Object
- #password=(new_password) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from RedisModel
all, #delete, delete_all, find, find_by, find_by_email, find_by_id, first, #initialize, #read_attribute_for_validation, #save, #save!, table, #table, #update
Constructor Details
This class inherits a constructor from RedisModel
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'app/models/user.rb', line 3 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/models/user.rb', line 3 def id @id end |
#password_digest ⇒ Object
Returns the value of attribute password_digest.
3 4 5 |
# File 'app/models/user.rb', line 3 def password_digest @password_digest end |
Instance Method Details
#authenticate(given_password) ⇒ Object
30 31 32 |
# File 'app/models/user.rb', line 30 def authenticate(given_password) password == given_password end |
#password ⇒ Object
21 22 23 |
# File 'app/models/user.rb', line 21 def password @password ||= Password.new(password_digest) end |
#password=(new_password) ⇒ Object
25 26 27 28 |
# File 'app/models/user.rb', line 25 def password=(new_password) @password = new_password self.password_digest = Password.create(@password) end |
#to_hash ⇒ Object
14 15 16 17 18 19 |
# File 'app/models/user.rb', line 14 def to_hash raw = { email: self.email, password_digest: password_digest } end |