Class: Valkyrie::Persistence::Solr::ORMConverter::DateTimeValue

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

Overview

Converts a datetime in Solr into a DateTime

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)


263
264
265
266
267
268
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 263

def self.handles?(value)
  return false unless value.to_s.start_with?("datetime-")
  DateTime.iso8601(value.sub(/^datetime-/, '')).utc
rescue
  false
end

Instance Method Details

#resultObject



270
271
272
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 270

def result
  DateTime.parse(value.sub(/^datetime-/, '')).utc
end