Skip to content

Instantly share code, notes, and snippets.

@Papierkorb
Created October 1, 2017 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Papierkorb/67a8f68189c8c82f7c15b189c6435a4a to your computer and use it in GitHub Desktop.
Save Papierkorb/67a8f68189c8c82f7c15b189c6435a4a to your computer and use it in GitHub Desktop.
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