lib/dry/schema/macros/value.rb in dry-schema-0.2.0 vs lib/dry/schema/macros/value.rb in dry-schema-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'dry/schema/macros/dsl'
module Dry
module Schema
module Macros
@@ -11,16 +13,21 @@
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
+ updated_type =
+ if current_type.respond_to?(:of)
+ current_type.of(schema.type_schema)
+ else
+ schema.type_schema
+ end
+
schema_dsl.set_type(name, updated_type)
end
- trace.evaluate(*predicates, **opts, &block)
-
+ trace.evaluate(*predicates, **opts)
trace.append(new(chain: false).instance_exec(&block)) if block
if trace.captures.empty?
raise ArgumentError, 'wrong number of arguments (given 0, expected at least 1)'
end