Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

More improvements to types

+16 -18
+10 -18
lib/literal/types.rb
··· 106 106 end 107 107 108 108 # Matches if the value responds to all the given methods. 109 - def _Interface(*methods) 110 - raise Literal::ArgumentError.new("_Interface type must have at least one method.") if methods.size < 1 111 - 112 - Literal::Types::InterfaceType.new(*methods) 109 + def _Interface(...) 110 + Literal::Types::InterfaceType.new(...) 113 111 end 114 112 115 113 # Matches if *all* given types are matched. 116 - def _Intersection(*types) 117 - raise Literal::ArgumentError.new("_Intersection type must have at least one type.") if types.size < 1 118 - 119 - Literal::Types::IntersectionType.new(*types) 114 + def _Intersection(...) 115 + Literal::Types::IntersectionType.new(...) 120 116 end 121 117 122 118 # Ensures the value is valid JSON data (i.e. it came from JSON.parse). ··· 129 125 Literal::Types::LambdaType 130 126 end 131 127 132 - def _Map(**shape) 133 - Literal::Types::MapType.new(**shape) 128 + def _Map(...) 129 + Literal::Types::MapType.new(...) 134 130 end 135 131 136 132 # Never matches any value. ··· 185 181 end 186 182 187 183 # Matches if the value is an `Array` and each element matches the given types in order. 188 - def _Tuple(*types) 189 - raise Literal::ArgumentError.new("_Tuple type must have at least one type.") if types.size < 1 190 - 191 - Literal::Types::TupleType.new(*types) 184 + def _Tuple(...) 185 + Literal::Types::TupleType.new(...) 192 186 end 193 187 194 188 # Matches if *any* given type is matched. 195 - def _Union(*types) 196 - raise Literal::ArgumentError.new("_Union type must have at least one type.") if types.size < 1 197 - 198 - Literal::Union.new(*types) 189 + def _Union(...) 190 + Literal::Union.new(...) 199 191 end 200 192 201 193 def _Void
+1
lib/literal/types/interface_type.rb
··· 3 3 # @api private 4 4 class Literal::Types::InterfaceType 5 5 def initialize(*methods) 6 + raise Literal::ArgumentError.new("_Interface type must have at least one method.") if methods.size < 1 6 7 @methods = methods 7 8 end 8 9
+2
lib/literal/types/intersection_type.rb
··· 3 3 # @api private 4 4 class Literal::Types::IntersectionType 5 5 def initialize(*types) 6 + raise Literal::ArgumentError.new("_Intersection type must have at least one type.") if types.size < 1 7 + 6 8 @types = types 7 9 end 8 10
+2
lib/literal/types/tuple_type.rb
··· 3 3 # @api private 4 4 class Literal::Types::TupleType 5 5 def initialize(*types) 6 + raise Literal::ArgumentError.new("_Tuple type must have at least one type.") if types.size < 1 7 + 6 8 @types = types 7 9 end 8 10
+1
lib/literal/union.rb
··· 4 4 include Enumerable 5 5 6 6 def initialize(*types) 7 + raise Literal::ArgumentError.new("_Union type must have at least one type.") if types.size < 1 7 8 @types = types 8 9 end 9 10