Class: Valkyrie::Persistence::Solr::ModelConverter::SharedStringPropertyValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/solr/model_converter.rb

Overview

Handles casting language-tagged strings when there are both language-tagged and non-language-tagged strings in Solr. Assumes English for non-language-tagged strings.

Instance Attribute Summary

Attributes inherited from ValueMapper

#calling_mapper, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValueMapper

for, #initialize, register

Constructor Details

This class inherits a constructor from Valkyrie::ValueMapper

Class Method Details

.handles?(value) ⇒ Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 245

def self.handles?(value)
  value.is_a?(Property) && value.value.is_a?(String) && value.scope.find { |x| x.is_a?(::RDF::Literal) }.present?
end

Instance Method Details

#resultObject



249
250
251
252
253
254
255
256
257
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 249

def result
  CompositeSolrRow.new(
    [
      calling_mapper.for(Property.new(value.key, value.value)).result,
      calling_mapper.for(Property.new("#{value.key}_lang", "eng")).result,
      calling_mapper.for(Property.new("#{value.key}_type", "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")).result
    ]
  )
end