h1. Classy Inheritance "You stay classy, inheritance" - Gibson h2. What For now, Classy Inheritance adds a depends_on class method to your ActiveRecord model so that you can define requisite objects. More functionality coming for optional relationships. You can define the relationship to be polymorphic:
class Picture < ActiveRecord::Base depends_on :image, :attrs => [:filename, :height, :width], :as => "imageable" endThis will look for "imageable_type" and "imageable_id" on the images table add set them accordingly. Or you can define a standard belongs_to relationship:
class User < ActiveRecord::Base depends_on :profile, :attrs => [:first_name, :last_name, :email] endh3. What does it do for me? Well, for starters you get pass-through methods added to your model. So, in the above User example you would get the following:
@user.first_name @user.last_name @user.email @user.first_name= @user.last_name= @user.email=This means you can use these attributes on your form and in your controller instead of having to worry about creating/updating a separate Profile model. For the above example, you'll also get a "find_with_profile" class method that will do the :include => :profile addition to your find call for you. h2. Installing
$ sudo gem install classy-inheritance # in environment.rb add: require "classy-inheritance"h2. How to submit patches The Clone URL: git://github.com/stonean/classy-inheritance.git Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above. I'm new to git and this whole opensource project admin gig, so please be patient with my stumbling around. h2. License This code is free to use under the terms of the MIT license.