Class: Valkyrie::Persistence::Fedora::Persister::ModelConverter::Property

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

Overview

Class modeling properties for Fedora LDP resources These map directly to attributes on the Valkyrie resources and generate a new graph or populate an existing graph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, key, value, adapter, resource) ⇒ Property

Returns a new instance of Property.

Parameters:



78
79
80
81
82
83
84
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 78

def initialize(subject, key, value, adapter, resource)
  @subject = subject
  @key = key
  @value = value
  @adapter = adapter
  @resource = resource
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



70
71
72
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 70

def adapter
  @adapter
end

#keyObject (readonly)

Returns the value of attribute key.



70
71
72
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 70

def key
  @key
end

#resourceObject (readonly)

Returns the value of attribute resource.



70
71
72
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 70

def resource
  @resource
end

#subjectObject (readonly)

Returns the value of attribute subject.



70
71
72
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 70

def subject
  @subject
end

#valueObject (readonly)

Returns the value of attribute value.



70
71
72
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 70

def value
  @value
end

Instance Method Details

#predicateRDF::URI

Retrieve the RDF predicate for this Valkyrie Resource attribute (being converted) This is used to generate RDF statements (triples) from Resource attributes

Returns:



99
100
101
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 99

def predicate
  schema.predicate_for(resource: resource, property: key)
end

#to_graph(graph = RDF::Graph.new) ⇒ RDF::Graph

Populate the RDF graph containing statements about the LDP container

Parameters:

  • graph (RDF::Graph) (defaults to: RDF::Graph.new)

Returns:

  • (RDF::Graph)


89
90
91
92
93
94
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 89

def to_graph(graph = RDF::Graph.new)
  Array(value).each do |val|
    graph << RDF::Statement.new(subject, predicate, val)
  end
  graph
end