Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
show all
- Defined in:
- app/models/user.rb
Constant Summary
collapse
- @@authorized_types =
[ 'Administrator', 'Designer', 'User' ]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#login ⇒ Object
When inheriting this can raise an exception on the new models
8
9
10
|
# File 'app/models/user.rb', line 8
def login
@login
end
|
#new_class_name ⇒ Object
When inheriting this can raise an exception on the new models
8
9
10
|
# File 'app/models/user.rb', line 8
def new_class_name
@new_class_name
end
|
Class Method Details
.find_for_authentication(conditions) ⇒ Object
66
67
68
69
|
# File 'app/models/user.rb', line 66
def find_for_authentication(conditions)
login = conditions.delete(:login)
find(:first, :conditions => ["username = ? OR email = ?", login, login])
end
|
.unprotected_attributes ⇒ Object
58
59
60
|
# File 'app/models/user.rb', line 58
def unprotected_attributes
@unprotected_attributes ||= [:name, :email, :username, :login, :password, :password_confirmation, :locale]
end
|
.unprotected_attributes=(array) ⇒ Object
62
63
64
|
# File 'app/models/user.rb', line 62
def unprotected_attributes=(array)
@unprotected_attributes = array.map{|att| att.to_sym }
end
|
Instance Method Details
#admin? ⇒ Boolean
41
42
43
|
# File 'app/models/user.rb', line 41
def admin?
has_role?(:admin)
end
|
#authorized? ⇒ Boolean
49
50
51
|
# File 'app/models/user.rb', line 49
def authorized?
@@authorized_types.include?(class_name)
end
|
#designer? ⇒ Boolean
45
46
47
|
# File 'app/models/user.rb', line 45
def designer?
has_role?(:designer)
end
|
#has_role?(role) ⇒ Boolean
53
54
55
|
# File 'app/models/user.rb', line 53
def has_role?(role)
class_name.downcase.to_sym == role.to_s.downcase.to_sym
end
|