Sha256: 215236b5dba4d048551fa97043137f94ad88d4aab758486cc90141b3e1678071

Contents?: true

Size: 857 Bytes

Versions: 181

Compression:

Stored size: 857 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] || v }
                  elsif value
                    options_hash[value&.downcase.strip] || value
                  end
                end.def_serializer do |value|
                  value
                end
              end
            end

          end
        end
      end
    end
  end
end

Version data entries

181 entries across 181 versions & 1 rubygems

Version Path
eco-helpers-2.4.9 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.8 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.7 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.6 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.5 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.4 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.4.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.3.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.3.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.2.5 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.2.4 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.2.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.2.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.2.1 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.12 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.11 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.10 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.9 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.8 lib/eco/api/common/people/default_parsers/select_parser.rb