lib/dry/schema/macros/value.rb in dry-schema-0.1.1 vs lib/dry/schema/macros/value.rb in dry-schema-0.2.0

- old
+ new

@@ -7,9 +7,18 @@ # # @api public class Value < DSL # @api private def call(*predicates, **opts, &block) + schema = predicates.detect { |predicate| predicate.is_a?(Processor) } + + if schema + current_type = schema_dsl.types[name] + updated_type = current_type.respond_to?(:of) ? current_type.of(schema.type_schema) : schema.type_schema + + schema_dsl.set_type(name, updated_type) + end + trace.evaluate(*predicates, **opts, &block) trace.append(new(chain: false).instance_exec(&block)) if block if trace.captures.empty?