Class: Dry::Schema::ValueCoercer Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/dry/schema/value_coercer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Used by the processors to coerce values in the input hash

Instance Method Summary collapse

Instance Method Details

#call(input) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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