Method: Typisch::Type::Tuple#check_type
- Defined in:
- lib/typisch/tuple.rb
#check_type(instance, &recursively_check_type) ⇒ Object
For now we’re only allowing Array as a tuple. We could allow any Enumerable, say, but a tuple is really not supposed to be in any way a lazy data structure, it’s something of fixed (usually short) length.
38 39 40 41 42 |
# File 'lib/typisch/tuple.rb', line 38 def check_type(instance, &recursively_check_type) ::Array === instance && instance.length == @types.length && @types.zip(instance).all?(&recursively_check_type) end |