Class: Valkyrie::Persistence::Shared::JSONValueMapper::HashValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/shared/json_value_mapper.rb

Overview

Converts RDF::Literal typed-literals from JSON-LD stored into an

{RDF::Literal}

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 value is a Hash containing the key “@value”

Parameters:

  • value (Object)

Returns:

  • (Boolean)


37
38
39
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 37

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

Instance Method Details

#resultRDF::Literal

Constructs a RDF::Literal object using the Object keyed to “@value” in the value Hash, as well as the language keyed to “@language” and datatype keyed to “@type”

Returns:



45
46
47
48
49
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 45

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