Sha256: dd3f8472385c3a95af5a332531707280132b343066bd7ae1dc8dd36f5a02ae96

Contents?: true

Size: 860 Bytes

Versions: 29

Compression:

Stored size: 860 Bytes

Contents

module Eco
  module API
    module Common
      module People
        class DefaultParsers
          class MultiParser < People::BaseParser

            def process
              @parsers.define_attribute(:multiple) do |parser|
                parser.def_parser  do |value|
                  return 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

            private
            
            def into_a(value)
              value = [] if value == nil
              value = [].push(value) unless value.is_a?(Array)
              value
            end

          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
eco-helpers-0.6.8 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.7 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.6 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.5 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.4 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.3 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.2 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.1 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.0 lib/eco/api/common/people/default_parsers/multi_parser.rb