Class: Valkyrie::Persistence::Solr::ORMConverter::NestedResourceValue

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

Overview

Converts a nested resource in solr into a Resource

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 determines whether or not this should be mapped to a Hash

Determines whether or not a string representation of an Object is prefixed with “serialized-”

Parameters:

  • value (Object)

Returns:

  • (Boolean)


267
268
269
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 267

def self.handles?(value)
  value.to_s.start_with?("serialized-")
end

Instance Method Details

#jsonString

Parses the JSON-serialized Hash value from the Solr field

Returns:

  • (String)


279
280
281
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 279

def json
  value.sub(/^serialized-/, '')
end

#resultHash

Uses the NestedResourceConverter to parse the JSON-serialized Hash and convert this to a Valkyrie Resource attribute Hash

Returns:

  • (Hash)


273
274
275
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 273

def result
  NestedResourceConverter.for(JSON.parse(json, symbolize_names: true)).result
end