Class: Valkyrie::Persistence::Solr::ModelConverter::LiteralPropertyValue

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

Overview

Handles casting language-typed RDF::Literals

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

Determines whether or not a Property value is an RDF literal

Parameters:

  • value (Object)

Returns:

  • (Boolean)


457
458
459
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 457

def self.handles?(value)
  value.is_a?(Property) && value.value.is_a?(::RDF::Literal)
end

Instance Method Details

#resultCompositeSolrRow

Constructs a CompositeSolrRow object with the language-tagged literal value

Returns:



463
464
465
466
467
468
469
470
471
472
473
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 463

def result
  key = value.key
  val = value.value
  CompositeSolrRow.new(
    [
      calling_mapper.for(Property.new(key, val.to_s)).result,
      calling_mapper.for(Property.new("#{key}_lang", val.language.to_s)).result,
      calling_mapper.for(Property.new("#{key}_type", val.datatype.to_s)).result
    ]
  )
end