Class: DorIndexing::Indexers::RoleMetadataIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/dor_indexing/indexers/role_metadata_indexer.rb

Overview

Indexes the administrative role metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cocina:) ⇒ RoleMetadataIndexer

Returns a new instance of RoleMetadataIndexer.



9
10
11
# File 'lib/dor_indexing/indexers/role_metadata_indexer.rb', line 9

def initialize(cocina:, **)
  @cocina = cocina
end

Instance Attribute Details

#cocinaObject (readonly)

Returns the value of attribute cocina.



7
8
9
# File 'lib/dor_indexing/indexers/role_metadata_indexer.rb', line 7

def cocina
  @cocina
end

Instance Method Details

#to_solrHash

rubocop:disable Metrics/AbcSize

Returns:

  • (Hash)

    the partial solr document for roleMetadata



15
16
17
18
19
20
21
# File 'lib/dor_indexing/indexers/role_metadata_indexer.rb', line 15

def to_solr
  Array(cocina.administrative.roles).each_with_object({}) do |role, solr_doc|
    solr_doc['apo_register_permissions_ssim'] = serialize(role.members) if role.name == 'dor-apo-manager'
    solr_doc["apo_role_#{role.name}_ssim"] = serialize(role.members.select { |member| member.type == 'workgroup' })
    solr_doc["apo_role_person_#{role.name}_ssim"] = serialize(role.members.select { |member| member.type == 'sunetid' })
  end
end