Sha256: 0eed1d4e67098ee41a4488179ec596a05a2ac223e2ece52cde16d32755900b07

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  ##
  # Indexes `*_groups`/`*_users` style permissions. We depend on these
  # permissions being up-to-date in the index to support `Hyrax::Ability`.
  #
  # @example
  #   class MyIndexer < Hyrax::Indexers::ResourceIndexer
  #     include Hyrax::PermissionIndexer
  #   end
  module PermissionIndexer
    def to_solr
      super.tap do |index_document|
        config      = Hydra.config.permissions
        permissions = resource.permission_manager || Hyrax::PermissionManager.new(resource: resource)

        index_document[config.edit.group] = permissions.edit_groups.to_a
        index_document[config.edit.individual] = permissions.edit_users.to_a
        index_document[config.read.group] = permissions.read_groups.to_a
        index_document[config.read.individual] = permissions.read_users.to_a
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/indexers/concerns/hyrax/permission_indexer.rb
hyrax-5.0.0 app/indexers/concerns/hyrax/permission_indexer.rb
hyrax-5.0.0.rc3 app/indexers/concerns/hyrax/permission_indexer.rb