Elixir Reflection

I define some objects that work fine; for metaprograms. Now I need to reflect the field properties defined in the model.

For example:

class Foo(Entity):
      bar = OneToMany('Bar')
      baz = ManyToMany('Baz')

What type of relationship is specified: "ManyToMany", "OneToMany" or even a simple "Field" and the purpose of the relationship?

Is there an easy way to reflect elixir objects?

+3
source share
1 answer

Elixir, Python, - class Foo dir(Foo), getattr(Foo, thename), type(theattr) isinstance .. 'Bar', Relationship ( OneToMany ManyToMany), r.of_kind r "".

inspect Python , dir/getattr/isinstance & c .

+4

Source: https://habr.com/ru/post/1707152/


All Articles