Module: ExcADG::Assertions
- Defined in:
- lib/excadg/assertions.rb
Overview
collection of simple assertions
Class Method Summary collapse
-
.is_a?(vars, clss) ⇒ Boolean
asserts that all vars are instances of one of the clss.
Class Method Details
.is_a?(vars, clss) ⇒ Boolean
asserts that all vars are instances of one of the clss
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/excadg/assertions.rb', line 11 def is_a? vars, clss return if vars.is_a?(Array) && clss == Array clss = [clss] unless clss.is_a? Array vars = [vars] unless vars.is_a? Array wrong_vars = vars.reject { |var| clss.any? { |cls| var.is_a? cls } } raise "vars #{wrong_vars} not of classes #{clss}" unless wrong_vars.empty? end |