Sha256: 051fb3c6acdff6ba1bd341654bd49f26001bde3d06af996bef134101b344f082
Contents?: true
Size: 729 Bytes
Versions: 1
Compression:
Stored size: 729 Bytes
Contents
# frozen_string_literal: true 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-schema-1.10.3 | lib/dry/schema/value_coercer.rb |