-
-
Save Papierkorb/67a8f68189c8c82f7c15b189c6435a4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro requires(test) | |
end | |
macro ensures(test) | |
end | |
module Contract | |
macro included | |
puts {{ @type.class_name }} | |
macro method_added(meth) | |
\{% puts "Method #{meth.name.stringify} added" %} | |
\{{ meth }} | |
end | |
end | |
end | |
class Foo | |
include Contract | |
requires var > 5 | |
def foo(var) | |
var * 5 | |
end | |
end | |
foo = Foo.new | |
foo.foo 9 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment