Class: Valkyrie::Persistence::Fedora::Persister::ModelConverter::NestedProperty

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

Overview

Class mapping Valkyrie attribute values which have already been

mapped to Valkyrie::Persistence::Fedora::Persister::ModelConverter::Property objects

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 the Valkyrie attribute value can be ordered

Parameters:

  • value (Object)

Returns:

  • (Boolean)


298
299
300
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 298

def self.handles?(value)
  value.is_a?(Property) && (value.value.is_a?(Hash) || value.value.is_a?(Valkyrie::Resource)) && value.value[:internal_resource]
end

Instance Method Details

#nested_graphRDF::Graph

Generate the “child” graph from the value in the ModelConverter::Property

Returns:

  • (RDF::Graph)


311
312
313
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 311

def nested_graph
  @nested_graph ||= ModelConverter.new(resource: Valkyrie::Types::Anything[value.value], adapter: value.adapter, subject_uri: subject_uri).convert.graph
end

#resultGraphProperty

Generate a new parent graph containing the child graph generated from the ModelConverter::Property objects

Returns:



304
305
306
307
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 304

def result
  nested_graph << RDF::Statement.new(value.subject, value.predicate, subject_uri)
  GraphProperty.new(value.subject, value.key, nested_graph, value.adapter, value.resource)
end

#subject_uriRDF::Graph

Generate a new RDF hash URI for the “child” graph for the ModelConverter::Property

Returns:

  • (RDF::Graph)


317
318
319
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 317

def subject_uri
  @subject_uri ||= ::RDF::URI(RDF::Node.new.to_s.gsub("_:", "#"))
end