Sha256: a8520335c3220e9dda69674fa858602890c16b0704918ce1befe635d88f6064c

Contents?: true

Size: 852 Bytes

Versions: 15

Compression:

Stored size: 852 Bytes

Contents

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

            def process
              @parsers.define_attribute(:select, dependencies: @options) do |parser|
                parser.def_parser  do |value, deps|
                  options_hash = deps[:select_hashes][deps["attr"]]
                  next value if !options_hash
                  if value.is_a?(Array)
                    value.map { |v| options_hash[v&.downcase.strip]  }.compact
                  elsif value
                    options_hash[value&.downcase.strip]
                  end
                end.def_serializer do |value|
                  value
                end
              end
            end

          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.6.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.6.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.6.1 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.6.0 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.10 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.9 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.8 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.7 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.6 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.5 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.4 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.5.1 lib/eco/api/common/people/default_parsers/select_parser.rb