Module: IAmICan::RoleGroup::Definition
- Defined in:
- lib/i_am_i_can/role_group/definition.rb
Instance Method Summary collapse
- #group_roles(*members, by_name:, which_can: [ ], obj: nil) ⇒ Object
- #have_and_group_roles(*members, by_name:) ⇒ Object (also: #has_and_groups_roles)
- #remove_roles(*members, from: nil) ⇒ Object
Instance Method Details
#group_roles(*members, by_name:, which_can: [ ], obj: nil) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/i_am_i_can/role_group/definition.rb', line 6 def group_roles *members, by_name:, which_can: [ ], obj: nil group = (i = i_am_i_can).role_group_model.where(name: by_name).first_or_create instances, names = Role.extract(members.tap(&:flatten!), i) assignment = group._members_exec(:assign, instances, name: names) ResultOf.members assignment, i, given: [instances, names] end |
#have_and_group_roles(*members, by_name:) ⇒ Object Also known as: has_and_groups_roles
19 20 21 22 |
# File 'lib/i_am_i_can/role_group/definition.rb', line 19 def have_and_group_roles *members, by_name: have_roles *members group_roles *members, by_name: by_name end |
#remove_roles(*members, from: nil) ⇒ Object
15 16 17 |
# File 'lib/i_am_i_can/role_group/definition.rb', line 15 def remove_roles *members, from: nil # TODO end |