Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Includes:
- DynamicMethods
- Defined in:
- app/models/user.rb
Overview
:nodoc:
Constant Summary collapse
- SaltLength =
:nodoc:
16
Instance Attribute Summary collapse
-
#password ⇒ Object
attr_accessible :first_name, :last_name.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from DynamicMethods
#dynamic_hash, #method_missing, #save, #save!, #validate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DynamicMethods
Instance Attribute Details
#password ⇒ Object
attr_accessible :first_name, :last_name
6 7 8 |
# File 'app/models/user.rb', line 6 def password @password end |
Class Method Details
.hash_password(val, salt = '') ⇒ Object
:nodoc:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/user.rb', line 26 def self.hash_password(val, salt = '') # :nodoc: require 'digest/sha1' # create the salt if we need to if salt.length != SaltLength salt = '' allowed_chars = (('a'..'f').to_a).concat(('0'..'9').to_a) SaltLength.times do salt << allowed_chars[rand(allowed_chars.length)] end end # now, let the hashing begin digest = Digest::SHA1.new digest << salt << val salt << digest.hexdigest end |
Instance Method Details
#fake_password_confirmation ⇒ Object
:nodoc:
44 45 46 47 48 49 50 51 |
# File 'app/models/user.rb', line 44 def fake_password_confirmation # :nodoc: # if password is blank, user is not trying to change it. # just appease the validator by setting something valid if @password.blank? @password = "imapassword" @password_confirmation = "imapassword" end end |
#name ⇒ Object
17 |
# File 'app/models/user.rb', line 17 def name ; [ first_name, last_name ].compact.join(' ') ; end |