Class: Valkyrie::Persistence::Fedora::Persister::ModelConverter::DateTimeValue

Inherits:
MappedFedoraValue show all
Defined in:
lib/valkyrie/persistence/fedora/persister/model_converter.rb

Overview

Class for mapping Property objects for DateTime values

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 value is a Property for DateTime values

Parameters:

  • value (Object)

Returns:

  • (Boolean)

456
457
458
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 456

def self.handles?(value)
  value.is_a?(Property) && value.value.is_a?(DateTime)
end

Instance Method Details

#resultValkyrie::Persistence::Fedora::Persister::ModelConverter::Property

Generates the Property for this DateTime This will first be mapped to an RDF::Literal::DateTime object such as “2018-08-08T11:24:18.2087-04:00”^^<example.com/predicate/valkyrie_datetime>


463
464
465
466
467
468
# File 'lib/valkyrie/persistence/fedora/persister/model_converter.rb', line 463

def result
  map_value(converted_value: RDF::Literal.new(
    value.value,
    datatype: PermissiveSchema.valkyrie_datetime
  ))
end