Sha256: b1f3a56173af4bec0ab409ea548b36eaf7f8e441023d98359adefd2c6af9daa1

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

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.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

1 entries across 1 versions & 1 rubygems

Version Path
i_am_i_can-4.3.1 lib/i_am_i_can/role_group/definition.rb