318
319
320
321
322
323
324
325
326
327
|
# File 'lib/parallelpipes.rb', line 318
def self.check(*values, &block)
values.each do |name, value, test_data|
if block
raise new("#{name} failed argument correctness test (value given was '#{value.inspect}')") unless yield(value, test_data)
else
is_array = test_data.class == Array
raise new("#{name} was of class #{value.class} instead of #{test_data.inspect} (value given was #{value.inspect})") unless (is_array ? test_data.include?(value.class) : value.class == test_data)
end
end
end
|