Class: Transcriber::Resource::Serialization::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/transcriber/resource/serialization/date.rb

Class Method Summary collapse

Class Method Details

.desserialize(value) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/transcriber/resource/serialization/date.rb', line 11

def self.desserialize(value)
  date = value.kind_of?(::Date) ? value : ::Date.parse(value)
  format = Transcriber.configuration.date_format
  format ? date.strftime(format) : date.to_s
rescue ArgumentError
  raise "value not desserializable: #{value}"
end

.serialize(value) ⇒ Object



5
6
7
8
9
# File 'lib/transcriber/resource/serialization/date.rb', line 5

def self.serialize(value)
  ::Date.parse value
rescue ArgumentError
  raise "value not serializable: #{value}"
end