Module: Codecs::DateTimeCodec
- 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
142 143 144 |
# File 'lib/emery/codecs.rb', line 142 def self.applicable?(type) type == DateTime end |
.deserialize(type, json_value) ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/emery/codecs.rb', line 145 def self.deserialize(type, json_value) T.check(String, json_value) begin DateTime.strptime(json_value, '%Y-%m-%dT%H:%M:%S') rescue raise JsonerError.new("Failed to parse DateTime from '#{json_value.inspect.to_s}' format %Y-%m-%dT%H:%M:%S is required") end end |