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

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

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

Returns:

  • (Boolean)


134
135
136
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 134

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

Instance Method Details

#nested_graphObject



143
144
145
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 143

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

#resultObject



138
139
140
141
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 138

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_uriObject



147
148
149
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 147

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