Module: CoreModels::Models::Concerns::RoleConcerns
- Included in:
- Role
- Defined in:
- lib/core_models/models/concerns/role_concerns.rb
Instance Method Summary collapse
- #add_permission=(name) ⇒ Object
- #change_permissions=(names) ⇒ Object
- #has_group?(name) ⇒ Boolean
- #has_permission?(name) ⇒ Boolean
- #permission_names ⇒ Object
- #remove_permission=(name) ⇒ Object
Instance Method Details
#add_permission=(name) ⇒ Object
17 18 19 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 17 def (name) self. << self..klass.find_by(permission_name: name) end |
#change_permissions=(names) ⇒ Object
21 22 23 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 21 def (names) self. = self..klass.where(permission_name: names) end |
#has_group?(name) ⇒ Boolean
9 10 11 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 9 def has_group?(name) self.groups.where(group_name: name).any? end |
#has_permission?(name) ⇒ Boolean
5 6 7 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 5 def (name) self..where(permission_name: name).any? end |
#permission_names ⇒ Object
13 14 15 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 13 def self..pluck(:permission_name) end |
#remove_permission=(name) ⇒ Object
25 26 27 |
# File 'lib/core_models/models/concerns/role_concerns.rb', line 25 def (name) self..delete(self..klass.find_by(permission_name: name)) end |