Class: DorIndexing::Builders::TopicBuilder

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

Overview

Builds the topic fields for a solr document

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter:, remove_trailing_punctuation:) ⇒ TopicBuilder

Returns a new instance of TopicBuilder.



13
14
15
16
# File 'lib/dor_indexing/builders/topic_builder.rb', line 13

def initialize(filter:, remove_trailing_punctuation:)
  @filter = filter
  @remove_trailing_punctuation = remove_trailing_punctuation
end

Class Method Details

.build(subjects, filter:, remove_trailing_punctuation: false) ⇒ Object

Parameters:

  • subjects (Array)
  • filter (String)

    can either be ‘topic’ or ‘name’



9
10
11
# File 'lib/dor_indexing/builders/topic_builder.rb', line 9

def self.build(subjects, filter:, remove_trailing_punctuation: false)
  new(filter:, remove_trailing_punctuation:).build(subjects)
end

Instance Method Details

#build(subjects) ⇒ Object



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

def build(subjects)
  topics(subjects).flat_map { |topic| flat_topic(topic) }.compact.uniq
end