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)


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

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



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

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

#resultObject



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

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



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

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