I am trying to get properties of a struct/class and adding those to a new class. But looks like instance_vars
macro only works to get property of self and not work for other classes. Any suggestion to achieve this?
struct Node
property name = "", endpoint = ""
end
struct Pool
property name = ""
end
# Expected
# struct PoolView
# property name = "", node_name = "", node_endpoint = ""
# end
struct PoolView
property name = ""
{% for v in Node.instance_vars %}
property {{ ("node_" + v.name.stringify).id }} = {{ v.default_value }}
{% end %}
end
pool_view = PoolView.new
puts pool_view
# Output:
# PoolView(@name="")