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

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

Overview

Class for mapping resource member IDs in an RDF linked list

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

Determines whether or not the Property statement references an RDF linked list

Parameters:

Returns:

  • (Boolean)


163
164
165
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 163

def self.handles?(value)
  value.statement.predicate == ::RDF::Vocab::IANA.first
end

Instance Method Details

#headRDF::URI

Retrieve the URI for the first element in the linked list

Returns:



181
182
183
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 181

def head
  scope.query([value.statement.subject, RDF::Vocab::IANA.first]).to_a.first.object
end

#resultCompositeApplicator

Constructs a CompositeApplicator object for each element in the RDF linked list Involves mapping to Property objects using an OrderedList

Returns:



170
171
172
173
174
175
176
177
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 170

def result
  value.statement.predicate = PermissiveSchema.member_ids
  values = OrderedList.new(scope, head, tail, adapter).to_a.map(&:proxy_for)
  values = values.map do |val|
    calling_mapper.for(Property.new(statement: RDF::Statement.new(value.statement.subject, value.statement.predicate, val), scope: value.scope, adapter: value.adapter)).result
  end
  CompositeApplicator.new(values)
end

#tailRDF::URI

Retrieve the URI for the last element in the linked list

Returns:



187
188
189
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 187

def tail
  scope.query([value.statement.subject, RDF::Vocab::IANA.last]).to_a.first.object
end