Sha256: b997b67b362f2b9b0ed9484c063073b493f293008840e0071c5e24e25133c41f
Contents?: true
Size: 672 Bytes
Versions: 93
Compression:
Stored size: 672 Bytes
Contents
class Eco::API::Common::People::DefaultParsers::DateParser < Eco::API::Common::Loaders::Parser attribute :date def parser(value, deps) value.is_a?(Array) ? value.map { |v| parse_date(v) } : parse_date(value) end def serializer(value, deps) value.is_a?(Array) ? value.map { |d| serialize_date(d) } : serialize_date(value) end private def parse_date(value) begin (value.to_s.empty?) ? nil : Date.parse(value) rescue nil end end def serialize_date(value) return value if value.is_a?(String) begin value && value.strftime('%Y-%m-%d') rescue nil end end end
Version data entries
93 entries across 93 versions & 1 rubygems