Class: Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes

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

Overview

Class for deriving an attribute Hash from a Fedora LDP resource graph

Defined Under Namespace

Classes: Applicator, BooleanValue, CompositeApplicator, CreatedAtValue, DateTimeValue, DenylistedValue, DifferentSubject, FedoraValue, FloatValue, IntegerValue, InternalModelValue, InternalURI, LiteralValue, MemberID, NestedValue, NonStringSingleApplicator, NullApplicator, OrderedProperty, Property, SingleApplicator, TimeValue, UpdatedAtValue, ValkyrieIDValue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph:, adapter:) ⇒ GraphToAttributes

Returns a new instance of GraphToAttributes.

Parameters:



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

def initialize(graph:, adapter:)
  @graph = graph
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



66
67
68
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 66

def adapter
  @adapter
end

#graphObject (readonly)

Returns the value of attribute graph.



66
67
68
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 66

def graph
  @graph
end

Instance Method Details

#attributesHash

Access the attributes populated by RDF graph statements

Returns:

  • (Hash)


87
88
89
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 87

def attributes
  @attributes ||= {}
end

#convertHash

Generates FedoraValue objects for each statement in the Fedora LDP resource graph

Using these objects, it then generates a Hash of Valkyrie Resource attributes

Returns:

  • (Hash)


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

def convert
  graph.each do |statement|
    FedoraValue.for(Property.new(statement: statement, scope: graph, adapter: adapter)).result.apply_to(attributes)
  end
  attributes
end