Hello!
From what I understand, the {{@type.class_vars}}
macro expression works only in the scope of a method.
Is there a workaround to obtain the same results, but within the @type
scope?
I’d like to automatically collect all the class variables of a module to define their type instead of doing it manually.
For example:
class C; end
# manual way
module M
@@a : C
@@b : C
...
# ... other code using the variables
end
# automatic way
module M
# currently doesn't work, but something similar would be nice
{for name in @type.class_vars.map(&.name)}
{{name.id}} : C
{% end %}
# ... other code using the variables
end