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)


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

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



217
218
219
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 217

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

#resultObject



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

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



221
222
223
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 221

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