lib/dry/schema/macros/value.rb in dry-schema-1.6.2 vs lib/dry/schema/macros/value.rb in dry-schema-1.7.0

- old
+ new

@@ -9,11 +9,16 @@ # A macro used for specifying predicates to be applied to values from a hash # # @api private class Value < DSL # @api private - def call(*predicates, **opts, &block) + def call(*args, **opts, &block) + types, predicates = args.partition { |arg| arg.is_a?(Dry::Types::Type) } + + constructor = types.select { |type| type.is_a?(Dry::Types::Constructor) }.reduce(:>>) schema = predicates.detect { |predicate| predicate.is_a?(Processor) } + + schema_dsl.set_type(name, constructor) if constructor type_spec = opts[:type_spec] if schema current_type = schema_dsl.types[name]