[Nitro] Partially solution.

Alexey Petrushin lists at ruby-forum.com
Thu Jun 5 16:03:46 EDT 2008

Partially solution. It's possible to implement subject this way:

    class Item
      property :name, String
      belongs_to :parent, Object

    class Container < Item
      has_many :items, Item

    class Folder < Item
      has_many :items, Item

But, there are major disadvantages:
- Code duplication, each 'Container' should explicitly include 'has_many 
- Instead of 'Item' you forced to use 'Container::Item' and 
'Folder::Item' and remember about it.
- Instead of one 'Item' table you got two distinct 'container_item' and 
'folder_item' tables.

So, this is not the best solution ... :(
Posted via http://www.ruby-forum.com/.

More information about the Nitro-general mailing list