Class: Valkyrie::Persistence::Solr::ORMConverter::DateTimeValue
- Inherits:
-
ValueMapper
- Object
- ValueMapper
- Valkyrie::Persistence::Solr::ORMConverter::DateTimeValue
- 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
Class Method Summary collapse
-
.handles?(value) ⇒ Boolean
Determines whether or not a string representation of an Object is prefixed with “datetime-”.
Instance Method Summary collapse
-
#result ⇒ Time
Parses and casts the Solr field value into a UTC DateTime value.
Methods inherited from ValueMapper
Constructor Details
This class inherits a constructor from Valkyrie::ValueMapper
Class Method Details
.handles?(value) ⇒ Boolean
Note:
this determines whether or not this should be mapped to a DateTime object
Determines whether or not a string representation of an Object is prefixed with “datetime-”
446 447 448 449 450 451 |
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 446 def self.handles?(value) return false unless value.to_s.start_with?("datetime-") DateTime.iso8601(value.sub(/^datetime-/, '')).new_offset(0) rescue false end |
Instance Method Details
#result ⇒ Time
Parses and casts the Solr field value into a UTC DateTime value
455 456 457 |
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 455 def result DateTime.parse(value.sub(/^datetime-/, '')).new_offset(0) end |