Class: Valkyrie::Persistence::Solr::ModelConverter::DateTimePropertyValue

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

Overview

Casts DateTime values into a recognizable string in Solr.

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)


224
225
226
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 224

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

Instance Method Details

#resultObject



228
229
230
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 228

def result
  calling_mapper.for(Property.new(value.key, "datetime-#{JSON.parse(to_datetime(value.value).to_json)}")).result
end