Sha256: 359b6fa7fba599fe1887613d1111506c89b8f1b4bbcbcce3edaeaec6c9c99d29
Contents?: true
Size: 885 Bytes
Versions: 62
Compression:
Stored size: 885 Bytes
Contents
module Eco module API module Common module People class DefaultParsers class DateParser < People::BaseParser def process @parsers.define_attribute(:date) do |parser| parser.def_parser do |value| value.is_a?(Array) ? value.map { |v| parse_date(v) } : parse_date(value) end.def_serializer do |value| value.is_a?(Array) ? value.map { |d| d && d.strftime('%Y-%m-%d') } : value && value.strftime('%Y-%m-%d') end end end private def parse_date(value) begin (value.to_s.empty?) ? nil : Time.parse(value) rescue nil end end end end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems