So depends_on graduated to a project called Classy Inheritance. Why the name difference? Well depends_on represents just one type of relationship. I expect other relationships to be added as needs arise. One such method I could see is “composed_of”, where the object wouldn’t be required.
Lockdown will be using Classy Inheritance for [...]
Archive for the ‘classy-inheritance’ Category
Classy Inheritance
Posted in classy-inheritance on May 29, 2008 | Comments Off
depends_on update(2)
Posted in classy-inheritance on May 28, 2008 | Comments Off
This update allows for non-polymorphic associations. For instance a user belongs_to a profile. To define this association add the following to the User model:
depends_on :profile, :attrs => [:first_name, :last_name, :email]
Notice an “:as” option has not been passed because this isn’t a polymorphic association. So instead of adding the has_one call, a belongs_to [...]
depends_on update
Posted in classy-inheritance on May 28, 2008 | Comments Off
I’ve updated the code for depends_on.
This update adds a dynamic method, so if you had the call:
depends_on :content, :attrs => [:name, :url ], :as => :presentable
Then you would get a “find_with_content” class method that does the :include for you.
depends_on
Posted in RubyOnRails, classy-inheritance on May 27, 2008 | Comments Off
For one of my projects I had the need for a polymorphic association in which one object required the existence of the other. I had written a specific version of this, but decided it could easily be abstracted. I didn’t go with the built in ActiveRecord polymorphic features as I wanted to strip [...]
