Class: Necromancer::DateTimeConverters::StringToDateConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::DateTimeConverters::StringToDateConverter
- Defined in:
- lib/necromancer/converters/date_time.rb
Overview
An object that converts a String to a Date
Instance Attribute Summary
Attributes inherited from Converter
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert a string value to a Date.
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 Date
23 24 25 26 27 28 |
# File 'lib/necromancer/converters/date_time.rb', line 23 def call(value, = {}) strict = .fetch(:strict, config.strict) Date.parse(value) rescue strict ? fail_conversion_type(value) : value end |