Sha256: d90c2c80434ca0837c686b1a3e0ddc0daa531acae3447e9d0c34d7a6b27bde40
Contents?: true
Size: 758 Bytes
Versions: 24
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true require "dry/core/equalizer" require "dry/initializer" module Dry module Schema # Used by the processors to coerce values in the input hash # # @api private class ValueCoercer extend Dry::Initializer include ::Dry::Equalizer(:type_schema) # @api private param :type_schema # @api private def call(input) if input.success? type_schema[input.to_h] else type_schema.each_with_object(EMPTY_HASH.dup) do |key, hash| name = key.name next unless input.key?(name) value = input[name] hash[name] = input.error?(name) ? value : key[value] end end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems