Skip to content

Instantly share code, notes, and snippets.

@reednj
Created April 1, 2016 02:30
Show Gist options
  • Save reednj/b5524bceaca17bbf594d2036cb4640e6 to your computer and use it in GitHub Desktop.
Save reednj/b5524bceaca17bbf594d2036cb4640e6 to your computer and use it in GitHub Desktop.
is_a! extension method for ruby
class Object
def is_a!(t, name = nil)
if !is_a? t
if name.nil?
raise "expected #{t} but got #{self.class}"
else
raise "#{name} requires #{t} but got #{self.class}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment