Skip to content

Commit 83f0d57

Browse files
committed
Add deprecation warnings about types
1 parent 00016d9 commit 83f0d57

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/dry/initializer/plugins/type_constraint.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def type
1414
end
1515

1616
def dry_type?
17-
type.class.ancestors.map(&:name).include? "Dry::Types::Builder"
17+
type.respond_to? :call
1818
end
1919

2020
def plain_type?
@@ -24,6 +24,9 @@ def plain_type?
2424
def module_type_constraint
2525
return unless plain_type?
2626

27+
warn "[DEPRECATION] support for ruby modules as type constraint" \
28+
" is deprecated. Use dry-types instead."
29+
2730
"fail #{TypeError}.new(:#{name}, #{type}, @#{name})" \
2831
" unless @#{name} == Dry::Initializer::UNDEFINED ||" \
2932
" #{type} === @#{name}"
@@ -44,6 +47,9 @@ def dry_type_constraint
4447
end
4548

4649
def object_type_constraint
50+
warn "[DEPRECATION] support for case equality (===) as type constraint" \
51+
" is deprecated. Use dry-types instead."
52+
4753
ivar = :"@#{name}"
4854
constraint = type
4955

0 commit comments

Comments
 (0)