Class: Valkyrie::Persistence::Fedora::Persister::ModelConverter
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::Persister::ModelConverter
- Defined in:
- lib/valkyrie/persistence/fedora/persister/model_converter.rb
Overview
Responsible for converting Resource to LDP::Container::Basic
Defined Under Namespace
Classes: BooleanValue, CompositeProperty, DateTimeValue, EnumerableValue, FedoraValue, GraphProperty, IdentifiableValue, IntegerValue, InternalValkyrieID, MappedFedoraValue, NestedInternalValkyrieID, NestedProperty, OrderedMembers, Property, TimeValue
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#subject_uri ⇒ Object
readonly
Returns the value of attribute subject_uri.
Instance Method Summary collapse
- #convert ⇒ Object
- #graph_resource ⇒ Object
-
#initialize(resource:, adapter:, subject_uri: RDF::URI("")) ⇒ ModelConverter
constructor
A new instance of ModelConverter.
- #properties ⇒ Object
- #property_converter ⇒ Object
- #subject ⇒ Object
Constructor Details
#initialize(resource:, adapter:, subject_uri: RDF::URI("")) ⇒ ModelConverter
Returns a new instance of ModelConverter.
8 9 10 11 12 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 8 def initialize(resource:, adapter:, subject_uri: RDF::URI("")) @resource = resource @adapter = adapter @subject_uri = subject_uri end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
6 7 8 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 6 def adapter @adapter end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 6 def resource @resource end |
#subject_uri ⇒ Object (readonly)
Returns the value of attribute subject_uri.
6 7 8 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 6 def subject_uri @subject_uri end |
Instance Method Details
#convert ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 14 def convert graph_resource.graph.delete([nil, nil, nil]) properties.each do |property| values = resource_attributes[property] output = property_converter.for(Property.new(subject_uri, property, values, adapter, resource)).result graph_resource.graph << output.to_graph end graph_resource end |
#graph_resource ⇒ Object
31 32 33 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 31 def graph_resource @graph_resource ||= ::Ldp::Container::Basic.new(connection, subject, nil, base_path) end |
#properties ⇒ Object
25 26 27 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 25 def properties resource_attributes.keys - [:new_record] end |
#property_converter ⇒ Object
39 40 41 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 39 def property_converter FedoraValue end |
#subject ⇒ Object
35 36 37 |
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 35 def subject adapter.id_to_uri(resource.id) if resource.try(:id) end |