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)

170
171
172
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 170

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:


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

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:


177
178
179
180
181
182
183
184
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 177

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:


194
195
196
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 194

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