# How do I define a multi-layer aggregation structure?

**URL:** <https://www.ruby-forum.com/t/how-do-i-define-a-multi-layer-aggregation-structure/91676>\
**Category:** Rails\
**Created:** [April 11, 2007, 2:03pm UTC](https://www.ruby-forum.com/t/how-do-i-define-a-multi-layer-aggregation-structure/91676 "2007-04-11T14:03:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [April 11, 2007, 2:03pm UTC](https://www.ruby-forum.com/t/how-do-i-define-a-multi-layer-aggregation-structure/91676/1 "2007-04-11T14:03:47Z")

</div>

Hi all,

I’ve posted this question before. Someone told me to see the RDoc of  
ActiveRecord::Associations::ClassMethods, but I cannot find any  
related information about multi-layer aggregation in this document.

This is what I’m doing now:  
A “material” has “mechanical\_feature”, “chemistry\_feature”,  
“physical\_feature” and “technical\_feature”. Each of these features has  
different amount of properties such as “elastic\_modulus”. I put all  
these properties in the “material” table and use aggregation to  
achieve the object model “material.mechanical\_feature”. So “material”  
extends “ActiveRecord::Base”, other composited classes  
don’t.“mechanical\_feature” has a series of “hardness” properties like  
“rockwell\_hardness”, “shore\_hardness”, etc. They are mapping to the  
corresponding columns of “material” table, of course. I’m thinking  
that I should create a class “hardness” and put all these kind of  
properties into it so that I can use  
“material.mechanical\_feature.hardness.rockwell” in my ruby code.

My question is that:  
Since “mechanical\_feature” is a composite class which doesn’t extend  
“ActiveRecord::Base”, I suppose it cannot use the “composed\_of”  
method. Then how can I make “hardness” class aggregation? Some folks  
told me that multi-layer aggregation is a ruby best-practice. Then how  
can I achieve this?

Thanks a lot!
