Class: Eco::API::Common::People::DefaultParsers::MultiParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/eco/api/common/people/default_parsers/multi_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
17
18
# File 'lib/eco/api/common/people/default_parsers/multi_parser.rb', line 8

def process
  @parsers.define_attribute(:multiple) do |parser|
    parser.def_parser  do |value|
      next value if value.is_a?(Array)
      value = value.split("|") if value&.include?("|")
      into_a(value)
    end.def_serializer do |value|
      into_a(value).join("|")
    end
  end
end