> Apart from dm-is-remixable. I kinda like having ONE 'comments' table
> rather than 5. I've looked at serveral solutions but none of them seem
> to work (outdated maybe).
>
I used dm-is-remixable and plain Ruby modules, and happy to not even
bother with polymorphic
associations in the first place. Polymorphic
associations are cocain of ORM world, "kinda nice" and "cool kids use
them" and "caused you no harm yet" until
it is too late.
Having just one table
instead of N is not that useful from practical point of view.
I personally only find object level polymorphism important, and how to
share bits of behavior with modules, and not
what tables those objects go to sleep to. After all, the whole point
of DM is to hide storage details from you.
http://gist.github.com/cef3c9bf2f756779aca2
This is callback methods idiom. It is useful in many simple cases with
lazy module evaluation trick.
Here callback methods approach won't work since you need to specify
option for each macro call.
class Widget
is :state_machine, :field => :activation
is :state_machine, :field => :face
end
Macros have only
one advantage: if you have multiple associations of the same kind, you
need options for each call and not one set of callback methods
per class.
Hope this helps.
MK
> Saw the gist u have posted ... very cool use of "class Xyz < Module".
Delays Module body evaluation so one can use validations, has/
belongs_to and
other class methods in it without having two inner modules.
> Took me quite sometime to figure out what it actually does.
Probably not so cool then ;)
MK