Does rails (or active record) have any way to conveniently define and take
advantage of the tree structure of containment?

  e.g. a Modules contains Name, Modules and Classes.

  A Class contains Name, Attributes.

  An Attribute contains a Name and a Type.

The tree-like containment relations can be exploited more (certainly
differently) from non-tree relationships (e.g. a Module imports other
Modules, a Class inherits a Class).

Thanks!