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:



72
73
74
75
76
77
78
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 72

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.



64
65
66
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 64

def adapter
  @adapter
end

#keyObject (readonly)

Returns the value of attribute key.



64
65
66
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 64

def key
  @key
end

#resourceObject (readonly)

Returns the value of attribute resource.



64
65
66
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 64

def resource
  @resource
end

#subjectObject (readonly)

Returns the value of attribute subject.



64
65
66
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 64

def subject
  @subject
end

#valueObject (readonly)

Returns the value of attribute value.



64
65
66
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 64

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:



93
94
95
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 93

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)


83
84
85
86
87
88
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 83

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