Sha256: 9fa047faf2136b5b107af8d2756b65859d0cd23263e746282d7243f70b7245ce
Contents?: true
Size: 836 Bytes
Versions: 2
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true module IAmICan module RoleGroup module Definition 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 %i[ group_role groups_role groups_roles ].each { |aname| alias_method aname, :group_roles } def remove_roles *members, from: nil # TODO end def have_and_group_roles *members, by_name: have_roles *members group_roles *members, by_name: by_name end alias has_and_groups_roles have_and_group_roles end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i_am_i_can-4.4.1 | lib/i_am_i_can/role_group/definition.rb |
i_am_i_can-4.4.0 | lib/i_am_i_can/role_group/definition.rb |