# \[ANN\] Classy Inheritance 0.2.1

**URL:** <https://www.ruby-forum.com/t/ann-classy-inheritance-0-2-1/139963>\
**Category:** Rails\
**Created:** [June 9, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/ann-classy-inheritance-0-2-1/139963 "2008-06-09T16:19:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [June 9, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/ann-classy-inheritance-0-2-1/139963/1 "2008-06-09T16:19:32Z")

</div>

Classy  
Inheritance[http://stonean.com/wiki/classy-inheritance/Classy-inheritance](http://stonean.com/wiki/classy-inheritance/Classy-inheritance)provides  
two ActiveRecord methods: depends\_on and can\_be.

Depends\_on allows you define another model for which the calling model  
requires. A common setup for this is User → Profile, where  
User.depends\_on  
:profile, :attrs =\> [:first\_name, :last\_name, :email]

This will add pass through methods so you can access the profile  
attributes  
define via the @user object: @user.first\_name. This also means you can  
do  
@user.first\_name = “Andrew”. So, your view can be cleaned up by  
removing  
any calls/usage of the Profile class/object. Classy inheritance will  
validate and save the requisite object. You will also get a  
User.find\_with\_profile method that will automatically do the :include =\>  
:profile for you.

It also supports polymorphic associations (was actually the reason it  
was  
created). Please check out the site  
documentation[http://stonean.com/wiki/classy-inheritance/Classy-inheritance](http://stonean.com/wiki/classy-inheritance/Classy-inheritance)for  
more details.

By the way, Classy Inheritance was written to use the methods exposed to  
developers such as belongs\_to, validates\_associated and so forth in  
order  
to avoid monkey patching the ActiveRecord code.

## thanks, andy

Andrew S.
