Class: Mirah::Serializers::DateSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/mirah/serializers.rb

Overview

Serialize types for a date in ISO 8601 format.

Instance Method Summary collapse

Instance Method Details

#deserialize(value) ⇒ Object



29
30
31
32
33
34
# File 'lib/mirah/serializers.rb', line 29

def deserialize(value)
  Date.iso8601(value) if value
rescue ArgumentError, TypeError
  # Invalid input
  nil
end

#serialize(value) ⇒ Object



25
26
27
# File 'lib/mirah/serializers.rb', line 25

def serialize(value)
  Date.parse(value.to_s).iso8601 if value
end