Module: CoreModels::Models::Concerns::GroupConcerns
- Included in:
- Group
- Defined in:
- lib/core_models/models/concerns/group_concerns.rb
Instance Method Summary collapse
- #add_role=(name) ⇒ Object
- #change_roles=(names) ⇒ Object
- #get_role(name) ⇒ Object
- #has_role?(name) ⇒ Boolean
- #remove_role=(name) ⇒ Object
- #role_names ⇒ Object
Instance Method Details
#add_role=(name) ⇒ Object
17 18 19 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 17 def add_role=(name) self.roles << self.roles.klass.find_by(role_name: name) end |
#change_roles=(names) ⇒ Object
21 22 23 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 21 def change_roles=(names) self.roles =self.roles.klass.where(role_name: names) end |
#get_role(name) ⇒ Object
9 10 11 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 9 def get_role(name) self.roles.find(name.parameterize) end |
#has_role?(name) ⇒ Boolean
5 6 7 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 5 def has_role?(name) self.roles.where(role_name: name).any? end |
#remove_role=(name) ⇒ Object
25 26 27 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 25 def remove_role=(name) self.roles.delete(self.roles.klass.find_by(role_name: name)) end |
#role_names ⇒ Object
13 14 15 |
# File 'lib/core_models/models/concerns/group_concerns.rb', line 13 def role_names self.roles.pluck(:role_name) end |