Class: Lesli::Role

Inherits:
ApplicationLesliRecord show all
Defined in:
app/models/lesli/role.rb

Defined Under Namespace

Classes: Power, Privilege

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.list(current_user, query, params) ⇒ Object

Return a list of roles that the user is able to work with according to object level permission



51
52
53
54
55
56
# File 'app/models/lesli/role.rb', line 51

def self.list(current_user, query, params)
    current_user..roles
    .where("object_level_permission <= ?", current_user.max_object_level_permission)
    .order(object_level_permission: :desc, name: :asc)
    .select(:id, :name, :object_level_permission)
end

Instance Method Details

#has_users?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/lesli/role.rb', line 60

def has_users?
    User::Role.where(role: self).count > 0
end