Class: Eco::API::Common::People::DefaultParsers::DateParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/eco/api/common/people/default_parsers/date_parser.rb

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize

Constructor Details

This class inherits a constructor from Eco::API::Common::People::BaseParser

Instance Method Details

#processObject



8
9
10
11
12
13
14
15
16
# File 'lib/eco/api/common/people/default_parsers/date_parser.rb', line 8

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