Hello, I want to iterate all my entity subclasses and then iterate all their instvars and generate some method for each instvar by a macro, something like this (there are entity classes already defined in another files with My::Entity
as superclass) :
module My::Entities
{% for cls in My::Entity.subclasses %}
class {{cls.id}}
def hard_coded_method_just_for_testing
puts "something"
end
{% for atr in @type.instance_vars %}
def {{atr.id}}
puts "--- getting attr #{{{atr.stringify}}}"
end
{% end %}
end
{% end %}
end
But methods in the nested for
macro cycle are not generated (method hard_coded_method_just_for_testing
is generated successfully for all classes), so iteration over subclasses is OK, but iteration over their instvars does nothing.
Thanks very much for advice.