Class: DorIndexing::Builders::AuthorBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dor_indexing/builders/author_builder.rb

Overview

Builds the author fields for a solr document

Instance Method Summary collapse

Constructor Details

#initialize(cocina_contributors) ⇒ AuthorBuilder

Returns a new instance of AuthorBuilder.



7
8
9
# File 'lib/dor_indexing/builders/author_builder.rb', line 7

def initialize(cocina_contributors)
  @cocina_contributors = Array(cocina_contributors)
end

Instance Method Details

#build_allObject



18
19
20
# File 'lib/dor_indexing/builders/author_builder.rb', line 18

def build_all
  NameBuilder.build_all(cocina_contributors.filter_map(&:name))
end

#build_primaryObject



11
12
13
14
15
16
# File 'lib/dor_indexing/builders/author_builder.rb', line 11

def build_primary
  contributor = primary_cocina_contributor || cocina_contributors.first
  return unless contributor

  NameBuilder.build_primary_name(contributor.name) if contributor
end