Skip to content

Instantly share code, notes, and snippets.

@haileys
Forked from tenderlove/trololol.rb
Last active December 21, 2015 06:29
Show Gist options
  • Save haileys/6264387 to your computer and use it in GitHub Desktop.
Save haileys/6264387 to your computer and use it in GitHub Desktop.
module Kernel
def int(mid)
meth = instance_method(mid)
define_method(mid) { |*args, &bk|
val = meth.bind(self).call(*args, &bk)
raise TypeError, "#{mid} did not return an Integer" unless val.is_a? Integer
val
}
mid
end
end
class Foo
public int def foo
10
end
end
Foo.new.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment