Class: Object

Inherits:
BasicObject
Defined in:
lib/martin/dsl.rb

Instance Method Summary collapse

Instance Method Details

#should_be_a(cls) ⇒ Object

Throw a TypeError unless this object’s type is cls

Parameters:

  • cls

    The class this object should be

Raises:

  • (TypeError)


5
6
7
# File 'lib/martin/dsl.rb', line 5

def should_be_a(cls)
    raise(TypeError, "#{self.to_s} must be of type #{cls.to_s}") unless self.is_a?(cls)
end