Class: Grandstand::User

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/grandstand/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'app/models/grandstand/user.rb', line 4

def password
  @password
end

Class Method Details

.authenticates_with(credentials) ⇒ Object



20
21
22
23
# File 'app/models/grandstand/user.rb', line 20

def authenticates_with(credentials)
  password = credentials.delete(:password)
  first(:conditions => credentials)
end

Instance Method Details

#authenticates_with?(check_password) ⇒ Boolean

Check whether or not a given password hashes out to this models’ stored password.

Returns:

  • (Boolean)


28
29
30
# File 'app/models/grandstand/user.rb', line 28

def authenticates_with?(check_password)
  encrypted_password == password_digest(check_password)
end

#mailtoObject

Provides a mailto: formatted link to this users’ e-mail address



33
34
35
# File 'app/models/grandstand/user.rb', line 33

def mailto
  "mailto:#{email}"
end

#nameObject

Creates a whitespace-cleaned combination of this users’ first and last names



39
40
41
42
43
# File 'app/models/grandstand/user.rb', line 39

def name
  return @name if @name
  name = [first_name, last_name].reject(&:blank?).join(' ')
  @name = name.blank? ? email : name
end