Sha256: 13477df632a90546a2eedb2eb86f338f0e1170d5c7f5c4727580dfa94151e3f5

Contents?: true

Size: 714 Bytes

Versions: 9

Compression:

Stored size: 714 Bytes

Contents

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

            def process
              @parsers.define_attribute(:number, dependencies: @options) do |parser|
                parser.def_parser  do |value, deps|
                  #deps[:schema]&.fields[deps["attr"]].parse_text(value)
                  value = value.to_s.strip == "" ? nil : (value.to_f rescue nil)
                end.def_serializer do |value|
                  value.is_a?(Array) ? value.map { |v| v.to_s } : value.to_s
                end
              end
            end

          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
eco-helpers-0.6.17 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.16 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.15 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.13 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.12 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.11 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.9 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.8 lib/eco/api/common/people/default_parsers/numeric_parser.rb
eco-helpers-0.6.7 lib/eco/api/common/people/default_parsers/numeric_parser.rb