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.1.7 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.6 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.5 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.4 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.3 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.2 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.1.1 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.68 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.67 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.66 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.65 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.64 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.63 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.62 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.61 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.60 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.59 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.58 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.57 lib/eco/api/common/people/default_parsers/select_parser.rb
eco-helpers-2.0.56 lib/eco/api/common/people/default_parsers/select_parser.rb