class Dry::Schema::ValueCoercer

Used by the processors to coerce values in the input hash

@api private

Public Instance Methods

call(input) click to toggle source

@api private

# File lib/dry/schema/value_coercer.rb, line 19
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