Class: Valkyrie::Persistence::Solr::ORMConverter::NestedResourceLiteral

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

Overview

Class for handling serialized Hashes for RDF literals in Solr fields

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

Note:

this is used to determine whether or not this is a RDF literal for an attribute

Determines whether or not an Object is a Hash with a string mapped to the “@value” key

Parameters:

  • value (Object)

Returns:

  • (Boolean)

353
354
355
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 353

def self.handles?(value)
  value.is_a?(Hash) && value[:@value]
end

Instance Method Details

#resultRDF::URI

Constructs a RDF::Literal object using the value keyed to :@value and language tag keyed to :@language in the Property Hash value

Returns:


359
360
361
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 359

def result
  RDF::Literal.new(value[:@value], language: value[:@language])
end