Module: Extlib::Assertions

Defined in:
lib/ixtlan/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#assert_kind_of(name, value, *klasses) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/ixtlan/monkey_patches.rb', line 13

def assert_kind_of(name, value, *klasses)
  # be less strict and allow matching class names to OK as well
  klasses.each { |k| return if value.kind_of?(k) or value.class.name == k.name }
  raise ArgumentError, "+#{name}+ should be #{klasses.map { |k| k.name } * ' or '}, but was #{value.class.name}", caller(2)
end