Class: User
Constant Summary collapse
- ROLES =
%w[admin content_manager]
Instance Method Summary collapse
-
#email ⇒ Object
Database authenticatable.
- #is?(role) ⇒ Boolean
-
#remember_created_at ⇒ Object
Rememberable.
-
#reset_password_token ⇒ Object
Recoverable.
- #roles ⇒ Object
- #roles=(roles) ⇒ Object
-
#sign_in_count ⇒ Object
Trackable.
Instance Method Details
#email ⇒ Object
Database authenticatable
15 |
# File 'app/models/user.rb', line 15 field :email, :type => String, :default => "" |
#is?(role) ⇒ Boolean
64 65 66 |
# File 'app/models/user.rb', line 64 def is?(role) roles.include?(role.to_s) end |
#remember_created_at ⇒ Object
Rememberable
26 |
# File 'app/models/user.rb', line 26 field :remember_created_at, :type => Time |
#reset_password_token ⇒ Object
Recoverable
22 |
# File 'app/models/user.rb', line 22 field :reset_password_token, :type => String |
#roles ⇒ Object
58 59 60 61 62 |
# File 'app/models/user.rb', line 58 def roles ROLES.reject do |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? end end |
#roles=(roles) ⇒ Object
54 55 56 |
# File 'app/models/user.rb', line 54 def roles=(roles) self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+) end |
#sign_in_count ⇒ Object
Trackable
29 |
# File 'app/models/user.rb', line 29 field :sign_in_count, :type => Integer, :default => 0 |