···106106 end
107107108108 # Matches if the value responds to all the given methods.
109109- def _Interface(*methods)
110110- raise Literal::ArgumentError.new("_Interface type must have at least one method.") if methods.size < 1
111111-112112- Literal::Types::InterfaceType.new(*methods)
109109+ def _Interface(...)
110110+ Literal::Types::InterfaceType.new(...)
113111 end
114112115113 # Matches if *all* given types are matched.
116116- def _Intersection(*types)
117117- raise Literal::ArgumentError.new("_Intersection type must have at least one type.") if types.size < 1
118118-119119- Literal::Types::IntersectionType.new(*types)
114114+ def _Intersection(...)
115115+ Literal::Types::IntersectionType.new(...)
120116 end
121117122118 # Ensures the value is valid JSON data (i.e. it came from JSON.parse).
···129125 Literal::Types::LambdaType
130126 end
131127132132- def _Map(**shape)
133133- Literal::Types::MapType.new(**shape)
128128+ def _Map(...)
129129+ Literal::Types::MapType.new(...)
134130 end
135131136132 # Never matches any value.
···185181 end
186182187183 # Matches if the value is an `Array` and each element matches the given types in order.
188188- def _Tuple(*types)
189189- raise Literal::ArgumentError.new("_Tuple type must have at least one type.") if types.size < 1
190190-191191- Literal::Types::TupleType.new(*types)
184184+ def _Tuple(...)
185185+ Literal::Types::TupleType.new(...)
192186 end
193187194188 # Matches if *any* given type is matched.
195195- def _Union(*types)
196196- raise Literal::ArgumentError.new("_Union type must have at least one type.") if types.size < 1
197197-198198- Literal::Union.new(*types)
189189+ def _Union(...)
190190+ Literal::Union.new(...)
199191 end
200192201193 def _Void
+1
lib/literal/types/interface_type.rb
···33# @api private
44class Literal::Types::InterfaceType
55 def initialize(*methods)
66+ raise Literal::ArgumentError.new("_Interface type must have at least one method.") if methods.size < 1
67 @methods = methods
78 end
89
+2
lib/literal/types/intersection_type.rb
···33# @api private
44class Literal::Types::IntersectionType
55 def initialize(*types)
66+ raise Literal::ArgumentError.new("_Intersection type must have at least one type.") if types.size < 1
77+68 @types = types
79 end
810
+2
lib/literal/types/tuple_type.rb
···33# @api private
44class Literal::Types::TupleType
55 def initialize(*types)
66+ raise Literal::ArgumentError.new("_Tuple type must have at least one type.") if types.size < 1
77+68 @types = types
79 end
810
+1
lib/literal/union.rb
···44 include Enumerable
5566 def initialize(*types)
77+ raise Literal::ArgumentError.new("_Union type must have at least one type.") if types.size < 1
78 @types = types
89 end
910