Class: Cyclid::API::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cyclid::API::User
- Defined in:
- app/cyclid/models/user.rb
Overview
Model for Users
Instance Attribute Summary collapse
-
#new_password ⇒ Object
Allow an unencryped password to be passed in via.
Class Method Summary collapse
-
.all_as_hash ⇒ Object
Return the collection of Users as an array of Hashes (instead of User objects).
Instance Method Summary collapse
-
#hash_new_password ⇒ Object
Generate a BCrypt2 password from the plaintext.
-
#password_changed? ⇒ Boolean
Check if the new_password attribute has changed.
Instance Attribute Details
#new_password ⇒ Object
Allow an unencryped password to be passed in via. new_password and ensure it is encrypted into password when the record is saved
45 46 47 |
# File 'app/cyclid/models/user.rb', line 45 def new_password @new_password end |
Class Method Details
.all_as_hash ⇒ Object
Return the collection of Users as an array of Hashes (instead of User objects)
29 30 31 |
# File 'app/cyclid/models/user.rb', line 29 def all_as_hash all.to_a.map(&:serializable_hash) end |
Instance Method Details
#hash_new_password ⇒ Object
Generate a BCrypt2 password from the plaintext
55 56 57 |
# File 'app/cyclid/models/user.rb', line 55 def hash_new_password self.password = BCrypt::Password.create(@new_password) end |
#password_changed? ⇒ Boolean
Check if the new_password attribute has changed
50 51 52 |
# File 'app/cyclid/models/user.rb', line 50 def password_changed? !@new_password.blank? end |