Class: Krikri::Enrichments::SplitOnProvidedLabel

Inherits:
Object
  • Object
show all
Includes:
Audumbla::FieldEnrichment
Defined in:
lib/krikri/enrichments/split_on_provided_label.rb

Overview

Splits a resource into multiple resources when multiple providedLabels are present. This is useful when a mapping error or limitation in partner data makes it impossible to split resoureces properly at mapping time.

@note: Properties other than ‘providedLabel` are retained by the original

node. This does not attempt to keep like properties together.

@note: Nodes created by this enrichment share a class with the original

input value.

Examples:

label_splitter = SplitOnProvidedLabel.new
node = DPLA::MAP::Agent.new(providedLabel: ['moomin', 'moominmama']
                            closeMatch:    'Moomintroll')

new_values = label_splitter.enrich_value(node)
new_values # => [#<DPLA::MAP::Agent:0x1...()>,
                 #<DPLA::MAP::Agent:0x2...()>]

new_values.map(&:providedLabel) # => [['moomin'], ['moominmama']]

See Also:

  • Audumbla::FieldEnrichment

Instance Method Summary collapse

Instance Method Details

#enrich_value(value) ⇒ Object

Parameters:

  • value (Object)

    the value to split

See Also:

  • Audumbla::FieldEnrichment#enrich_value


30
31
32
33
34
35
# File 'lib/krikri/enrichments/split_on_provided_label.rb', line 30

def enrich_value(value)
  return value unless value.is_a?(ActiveTriples::Resource) &&
                      value.respond_to?(:providedLabel)
  return value unless value.providedLabel.count > 1
  split_provided(value)
end