Class: User

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/models/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object (protected)



47
48
49
# File 'lib/models/user.rb', line 47

def method_missing(m, *args)
  return false
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



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

def password_confirmation
  @password_confirmation
end

Class Method Details

.authenticate(email, pass) ⇒ Object



17
18
19
20
21
22
# File 'lib/models/user.rb', line 17

def self.authenticate(email, pass)
  current_user = first(:email => email)
  return nil if current_user.nil?
  return current_user if User.encrypt(pass, current_user.salt) == current_user.hashed_password
  nil
end

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/models/user.rb', line 30

def admin?
  self.permission_level == -1 || self.id == 1
end