Class: User

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

Instance Method Summary collapse

Instance Method Details

#priveleged?(role, action) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'app/models/user.rb', line 29

def priveleged?(role, action)
  return true if root
  ur = user_roles.includes(:role).find{|x| x.role.keyword == role.to_s}
  ur.blank? ? false : ur.priveleged?(action)
end

#role?(role) ⇒ Boolean

METHODS

Returns:

  • (Boolean)


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

def role?(role)
  return true if root
  return roles.map{|x| x.keyword}.include? role.to_s
end

#titleObject



35
36
37
# File 'app/models/user.rb', line 35

def title
  email
end