···3232 autoload :TupleType, "literal/types/tuple_type"
3333 autoload :VoidType, "literal/types/void_type"
34343535- # Matches any value except `nil`. Use `_Nilable(_Any)` to match any value including `nil`.
3535+ # Matches any value except `nil`. Use `_Nilable(_Any)` or `_Void` to match any value including `nil`.
3636 def _Any
3737 Literal::Types::AnyType
3838 end
39394040 # Matches if the value is an `Array` and all the elements match the given type.
4141- def _Array(type)
4242- Literal::Types::ArrayType.new(type)
4141+ def _Array(...)
4242+ Literal::Types::ArrayType.new(...)
4343 end
44444545 # Matches if the value is `true` or `false`.
···4848 end
49495050 # Matches if the value responds to `#call`.
5151- def _Callable(type = nil)
5151+ def _Callable
5252 Literal::Types::CallableType
5353 end
54545555 # Matches if the value either the given class or a subclass of it.
5656- def _Class(type)
5757- Literal::Types::ClassType.new(type)
5656+ def _Class(...)
5757+ Literal::Types::ClassType.new(...)
5858 end
59596060 # Similar to `_Intersection`, but allows you to specify attribute constraints as keyword arguments.
6161 # @example
6262 # _Constraint(Array, size: 1..3)
6363- def _Constraint(*constraints, **attributes)
6464- Literal::Types::ConstraintType.new(*constraints, **attributes)
6363+ def _Constraint(...)
6464+ Literal::Types::ConstraintType.new(...)
6565 end
66666767 # Matches if the value is a descendant of the given class.
6868- def _Descendant(type)
6969- Literal::Types::DescendantType.new(type)
6868+ def _Descendant(...)
6969+ Literal::Types::DescendantType.new(...)
7070 end
71717272 # Matches if the value is an `Enumerable` and all its elements match the given type.
7373- def _Enumerable(type)
7474- Literal::Types::EnumerableType.new(type)
7373+ def _Enumerable(...)
7474+ Literal::Types::EnumerableType.new(...)
7575 end
76767777 # Matches *"falsy"* values (`nil` and `false`).
···8282 # Matches if the value is a `Float` and matches the given constraint.
8383 # You could use a `Range`, for example, as a constraint.
8484 # If you don't need a constraint, use `Float` instead of `_Float`.
8585- def _Float(constraint)
8686- Literal::Types::FloatType.new(constraint)
8585+ def _Float(...)
8686+ Literal::Types::FloatType.new(...)
8787 end
88888989 # Matches if the value is *frozen*.
9090- def _Frozen(type)
9191- Literal::Types::FrozenType.new(type)
9090+ def _Frozen(...)
9191+ Literal::Types::FrozenType.new(...)
9292 end
93939494 # Matches if the value is a `Hash` and all the keys and values match the given types.
9595- def _Hash(key_type, value_type)
9696- Literal::Types::HashType.new(key_type, value_type)
9595+ def _Hash(...)
9696+ Literal::Types::HashType.new(...)
9797 end
98989999 # Matches if the value is an `Integer` and matches the given constraint.
···101101 # If you don't need a constraint, use `Integer` instead of `_Integer`.
102102 # @example
103103 # attribute :age, _Integer(18..127)
104104- def _Integer(constraint)
105105- Literal::Types::IntegerType.new(constraint)
104104+ def _Integer(...)
105105+ Literal::Types::IntegerType.new(...)
106106 end
107107108108 # Matches if the value responds to all the given methods.
···130130 end
131131132132 def _Map(**shape)
133133- Literal::Types::MapType
133133+ Literal::Types::MapType.new(**shape)
134134 end
135135136136 # Never matches any value.
···139139 end
140140141141 # Matches if the value is either `nil` or the given type.
142142- def _Nilable(type)
143143- Literal::Types::NilableType.new(type)
142142+ def _Nilable(...)
143143+ Literal::Types::NilableType.new(...)
144144 end
145145146146 # Matches if the given type is *not* matched.
147147- def _Not(type)
148148- Literal::Types::NotType.new(type)
147147+ def _Not(...)
148148+ Literal::Types::NotType.new(...)
149149 end
150150151151 # Matches if the value is a `Proc` or responds to `#to_proc`.
···154154 end
155155156156 # Matches if the value is a `Range` of the given type.
157157- def _Range(type)
158158- Literal::Types::RangeType.new(type)
157157+ def _Range(...)
158158+ Literal::Types::RangeType.new(...)
159159 end
160160161161 # Matches if the value is a `Set` and all the elements match the given type.
162162- def _Set(type)
163163- Literal::Types::SetType.new(type)
162162+ def _Set(...)
163163+ Literal::Types::SetType.new(...)
164164 end
165165166166 # Ensures a value matches the given shape of a Hash
167167- def _Shape(*constraints, **shape)
168168- Literal::Types::ShapeType.new(*constraints, **shape)
167167+ def _Shape(...)
168168+ Literal::Types::ShapeType.new(...)
169169 end
170170171171- # Matches if the value is a `String` and matches the given constraint.
172172- # You could use a `Regexp`, for example, as a constraint.
173173- # If you don't need a constraint, use `String` instead of `_String`.
174174- def _String(constraint)
175175- Literal::Types::StringType.new(constraint)
171171+ # Matches if the value is a `String` and matches the given constraints.
172172+ # If you don't need any constraints, use `String` instead of `_String`.
173173+ def _String(...)
174174+ Literal::Types::StringType.new(...)
176175 end
177176178177 # Matches if the value is a `Symbol` and matches the given constraint.
179179- def _Symbol(constraint)
180180- Literal::Types::SymbolType.new(constraint)
178178+ def _Symbol(...)
179179+ Literal::Types::SymbolType.new(...)
181180 end
182181183182 # Matches *"truthy"* values (anything except `nil` and `false`).