Skip to content

Instantly share code, notes, and snippets.

@Groogy
Created July 9, 2017 11:36
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 Groogy/68bc858c648968abfa0abed474941f34 to your computer and use it in GitHub Desktop.
Save Groogy/68bc858c648968abfa0abed474941f34 to your computer and use it in GitHub Desktop.
macro finished
{% for definition in Crystal::Clear::CLASS_COMPILE_DATA %}
class {{definition[0]}}
Crystal::Clear::CLASS_RUNTIME_DATA << Crystal::Clear::ClassData({{definition[0]}}).new()
def {{definition[1]}}
{% for condition in definition[2] %}
if(({{condition}}) == false)
raise Crystal::Clear::Exception.new("Failed {{definition[0]}} require contract: {{condition}}")
end
{% end %}
previous_def
{% for condition in definition[3] %}
if(({{condition}}) == false)
raise Crystal::Clear::Exception.new("Failed {{definition[0]}} ensure contract: {{condition}}")
end
{% end %}
end
end
{% end %}
end
puts Crystal::Clear::CLASS_RUNTIME_DATA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment