Module: IAmICan::RoleGroup::Definition

Defined in:
lib/i_am_i_can/role_group/definition.rb

Instance Method Summary collapse

Instance Method Details

#group_roles(*members, by_name:, which_can: [ ], obj: nil) ⇒ Object



4
5
6
7
8
9
# File 'lib/i_am_i_can/role_group/definition.rb', line 4

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



17
18
19
20
# File 'lib/i_am_i_can/role_group/definition.rb', line 17

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



13
14
15
# File 'lib/i_am_i_can/role_group/definition.rb', line 13

def remove_roles *members, from: nil
  # TODO
end