lib/eco/api/common/people/default_parsers/multi_parser.rb in eco-helpers-1.5.1 vs lib/eco/api/common/people/default_parsers/multi_parser.rb in eco-helpers-1.5.2
- old
+ new
@@ -1,33 +1,21 @@
-module Eco
- module API
- module Common
- module People
- class DefaultParsers
- class MultiParser < People::BaseParser
+class Eco::API::Common::People::DefaultParsers::MultiParser < Eco::API::Common::Loaders::Parser
+ attribute :multiple
- 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
+ def parser(value, deps)
+ into_a(value)
+ end
- private
+ def serializer(value, deps)
+ into_a(value).join("|")
+ end
- def into_a(value)
- value = [] if value == nil
- value = [].push(value) unless value.is_a?(Array)
- value
- end
+ private
- end
- end
- end
- end
+ def into_a(value)
+ return [] if value.nil?
+ return value if value.is_a?(Array)
+ return value.split("|") if value.is_a?(String) && value.include?("|")
+ [].push(value)
end
+
end