219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/cube/interfaces.rb', line 219
def check_type(t, v)
if t.is_a?(Set)
unless t.any? { |tp| check_type(tp, v) rescue false }
raise Cube::Interface::TypeMismatchError,
"#{v.inspect} is not any of #{tp.to_a}" unless v.is_a?(tp)
end
return
end
if t.is_a? Array
raise Cube::Interface::TypeMismatchError,
"#{v} is not an Array" unless v.is_a? Array
check_type(t.first, v.first)
check_type(t.first, v.last)
return
end
raise Cube::Interface::TypeMismatchError, "#{v.inspect} is not type #{t}" unless v.is_a? t
true
end
|