Class: Valkyrie::Persistence::Solr::ModelConverter::NestedObjectValue

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

Overview

Casts nested resources into a JSON string in solr.

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 a Hash

Parameters:

  • value (Object)

Returns:

  • (Boolean)

233
234
235
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 233

def self.handles?(value)
  value.value.is_a?(Hash) || value.value.is_a?(Valkyrie::Resource)
end

Instance Method Details

#resultSolrRow

Note:

this prepends the string “serialized-” to the value indexed in Solr

Constructs a SolrRow object for a Property with a Hash value This is indexed as a stored multivalued text


243
244
245
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 243

def result
  SolrRow.new(key: value.key, fields: ["tsim"], values: "serialized-#{value.value.to_json}")
end