Allows you check if an object match a class expression. It is typically used to check the type of method paraameters. It is an alternative to using Ruby-3 .rbs files but with a different syntax and only dynamic checks Typically you'll include the Constrain module and use #constrain to check the type of method parameters: include Constrain # f takes a String and an array of Integer objects. Raise a Constrain::Error # if parameters doesn't have the expected types def f(a, b) constrain a, String constrain b, [Integer] end Constrain works with ruby-2 (and maybe ruby-3)
Required Ruby Version
>= 0
Authors
Claus Rasmussen
Versions
-
0.10.0
-
source
- 0.10.0 source December 18, 2023 (10.5 KB)
-
-
0.9.0
-
source
- 0.9.0 source January 21, 2023 (10 KB)
-
-
0.8.0
-
source
- 0.8.0 source September 17, 2022 (10 KB)
-
-
0.7.0
-
source
- 0.7.0 source September 03, 2022 (10 KB)
-
-
0.6.0
-
source
- 0.6.0 source July 20, 2022 (10 KB)
-