[Nitro] Partially solution.

* William william.full.moon at gmail.com
Sat Jun 7 14:51:05 EDT 2008


Thanks there Alexey

I love this post!  I have a design need for exactly thing like (both) 'Item'
and 'Container'.

As well, I'd like to make a "generic" 'Container' that cna accept 'Items"
sub-clases too.

I'd like though to do ...

            *class *Data_Table_stuff
                *property*     subclass-of-Item
                *property*     subclass-of-Container

            *end *# Data_Table_stuff

I'll admit that I'm sitting back on this.  My issuer -- Still some solid Og
base is a precursor.

:-)


2008/6/6 Alexey Petrushin <lists at ruby-forum.com>:

> Partially solution. It's possible to implement subject this way:
>
>    class Item
>      property :name, String
>      belongs_to :parent, Object
>    end
>
>    class Container < Item
>      has_many :items, Item
>    end
>
>    class Folder < Item
>      has_many :items, Item
>    end
>
> 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/.
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>



-- 
aloha,
\_w_/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/nitro-general/attachments/20080608/a491c359/attachment.html>


More information about the Nitro-general mailing list