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-1.0.3 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.9.5 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-1.0.2 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.9.4 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.9.3 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.9.2 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.9.1 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.8.4 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.8.3 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.8.2 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.8.1 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.7.2 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.7.1 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.17 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.16 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.15 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.13 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.12 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.11 lib/eco/api/common/people/default_parsers/multi_parser.rb
eco-helpers-0.6.9 lib/eco/api/common/people/default_parsers/multi_parser.rb