lib/dry/schema/trace.rb in dry-schema-0.3.0 vs lib/dry/schema/trace.rb in dry-schema-0.4.0

- old
+ new

@@ -27,27 +27,35 @@ @compiler = compiler @captures = [] end # @api private - def evaluate(*predicates, **opts, &block) + def evaluate(*predicates, **opts) pred_opts = opts.dup pred_opts.delete(:type_spec) predicates.each do |predicate| if predicate.respond_to?(:call) append(predicate) + elsif predicate.is_a?(::Hash) + evaluate_hash_predicates(predicate) elsif predicate.is_a?(::Array) append(predicate.map { |pred| __send__(pred) }.reduce(:|)) else append(__send__(predicate)) end end - pred_opts.each do |predicate, *args| + evaluate_hash_predicates(pred_opts) + + self + end + + # @api private + def evaluate_hash_predicates(predicates) + predicates.each do |predicate, *args| append(__send__(predicate, *args)) end - self end # @api private def append(op)