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

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

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

Returns:

  • (Boolean)


196
197
198
199
200
201
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 196

def self.handles?(value)
  value.statement.object.is_a?(RDF::URI) && value.statement.object.to_s.include?("#") &&
    (value.statement.object.to_s.start_with?("#") ||
     value.statement.object.to_s.start_with?(value.adapter.connection_prefix)) &&
    value.scope.query([value.statement.object, nil, nil]).map(&:predicate).include?(::RDF::Vocab::IANA.first)
end

Instance Method Details

#headObject



211
212
213
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 211

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

#resultObject



203
204
205
206
207
208
209
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 203

def result
  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

#tailObject



215
216
217
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 215

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