Class: Necromancer::DateTimeConverters::StringToDateTimeConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::DateTimeConverters::StringToDateTimeConverter
- Defined in:
- lib/necromancer/converters/date_time.rb
Overview
An object that converts a String to a DateTime
Instance Attribute Summary
Attributes inherited from Converter
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert a string value to a DateTime.
Methods inherited from Converter
create, #fail_conversion_type, #initialize
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, options = {}) ⇒ Object
Convert a string value to a DateTime
40 41 42 43 44 45 |
# File 'lib/necromancer/converters/date_time.rb', line 40 def call(value, = {}) strict = .fetch(:strict, config.strict) DateTime.parse(value) rescue strict ? fail_conversion_type(value) : value end |