Module: Codecs::DateCodec
- Defined in:
- lib/emery/codecs.rb
Class Method Summary collapse
- .applicable?(type) ⇒ Boolean
- .deserialize(type, json_value) ⇒ Object
- .serialize(type, value) ⇒ Object
Class Method Details
.applicable?(type) ⇒ Boolean
160 161 162 |
# File 'lib/emery/codecs.rb', line 160 def self.applicable?(type) type == Date end |
.deserialize(type, json_value) ⇒ Object
163 164 165 166 167 168 169 170 |
# File 'lib/emery/codecs.rb', line 163 def self.deserialize(type, json_value) T.check(String, json_value) begin Date.strptime(json_value, '%Y-%m-%d') rescue raise JsonerError.new("Failed to parse Date from '#{json_value.inspect.to_s}' format %Y-%m-%d is required") end end |