Class: Valkyrie::Persistence::Solr::ORMConverter::NestedResourceValue
- Inherits:
-
ValueMapper
- Object
- ValueMapper
- Valkyrie::Persistence::Solr::ORMConverter::NestedResourceValue
- 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
Class Method Summary collapse
-
.handles?(value) ⇒ Boolean
Determines whether or not a string representation of an Object is prefixed with “serialized-”.
Instance Method Summary collapse
-
#json ⇒ String
Parses the JSON-serialized Hash value from the Solr field.
-
#result ⇒ Hash
Uses the NestedResourceConverter to parse the JSON-serialized Hash and convert this to a Valkyrie Resource attribute Hash.
Methods inherited from ValueMapper
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-”
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
#json ⇒ String
Parses the JSON-serialized Hash value from the Solr field
279 280 281 |
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 279 def json value.sub(/^serialized-/, '') end |
#result ⇒ Hash
Uses the NestedResourceConverter to parse the JSON-serialized Hash and convert this to a Valkyrie Resource attribute 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 |