Class: User

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/user.rb

Constant Summary collapse

ROLES =
%w[admin content_manager]

Instance Method Summary collapse

Instance Method Details

#emailObject

Database authenticatable



15
# File 'app/models/user.rb', line 15

field :email,              :type => String, :default => ""

#is?(role) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/models/user.rb', line 64

def is?(role)
  roles.include?(role.to_s)
end

#remember_created_atObject

Rememberable



26
# File 'app/models/user.rb', line 26

field :remember_created_at, :type => Time

#reset_password_tokenObject

Recoverable



22
# File 'app/models/user.rb', line 22

field :reset_password_token,   :type => String

#rolesObject



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_countObject

Trackable



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

field :sign_in_count,      :type => Integer, :default => 0