Class: Formotion::Conditions

Inherits:
Object
  • Object
show all
Defined in:
lib/formotion/exceptions.rb

Class Method Summary collapse

Class Method Details

.assert_class(obj, klass) ⇒ Object



14
15
16
17
18
# File 'lib/formotion/exceptions.rb', line 14

def assert_class(obj, klass)
  if not obj.is_a? klass
    raise Formotion::InvalidClassError, "#{obj.inspect} of class #{obj.class.to_s} is not of class #{klass.to_s}"
  end
end

.assert_nil_or_boolean(obj) ⇒ Object



8
9
10
11
12
# File 'lib/formotion/exceptions.rb', line 8

def assert_nil_or_boolean(obj)
  if not (obj.nil? or obj.is_a? TrueClass or obj.is_a? FalseClass)
    raise Formotion::InvalidClassError, "#{obj.inspect} should be nil, true, or false, but is #{obj.class.to_s}"
  end
end