Module: Hyrax::PermissionIndexer

Included in:
Indexers::AdministrativeSetIndexer, Indexers::FileSetIndexer, Indexers::PcdmCollectionIndexer, Indexers::PcdmObjectIndexer
Defined in:
app/indexers/concerns/hyrax/permission_indexer.rb

Overview

Indexes ‘*_groups`/`*_users` style permissions. We depend on these permissions being up-to-date in the index to support `Hyrax::Ability`.

Examples:

class MyIndexer < Hyrax::Indexers::ResourceIndexer
  include Hyrax::PermissionIndexer
end

Instance Method Summary collapse

Instance Method Details

#to_solrObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/indexers/concerns/hyrax/permission_indexer.rb', line 13

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