Module: Hyrax::PermissionIndexer

Included in:
PcdmCollectionIndexer, ValkyrieFileSetIndexer, ValkyrieWorkIndexer
Defined in:
app/indexers/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::ValkyrieIndexer
  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/hyrax/permission_indexer.rb', line 13

def to_solr
  super.tap do |index_document|
    config      = Hydra.config.permissions
    permissions = 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