depends_on polymorphic association

Hello everyone,

So I wrote this little piece of code:

Sorry for the blog link, but this was necessary for code formatting and long description.

Anyway, I just wanted to know if something like this already exists? If not, I would love feedback on how to make it better.

thanks, andy