On 25.07.2007 23:11, Trans wrote:
> I have a little design conundrum. I'm not sure the best way to model
> this. Basically I have two model "parts" and I want to support two
> ways of using them. Eg.
> 
>   class Part1
>     attr_accessor :a, :b, :x
>   end
> 
>   class Part2
>     attr_accessor :x, :y, :z
>   end
> 
> Now in the first case I want effectively:
> 
>   class Model1 < Part1
>     def subpart
>       @subpart ||= Part2.new
>     end
>   end
> 
> but in the second I want the equivalent of:
> 
>   class Model2 < Part1 < Part2
> 
> but obviously I can't do multiple inheritance.
> 
> So I've been trying to figure out the best way to do it. Do I use
> modules? Do I use Forwardable? What's the cleanest, fastest, least
> troubling way to go about it?

It's difficult to comment without knowing the domain or your use case. 
IMHO the fact that you want different inheritance hierarchies indicates 
that there is something wrong, namely inheritance might not be the best 
approach here.  It seems like composition would be better but since I do 
not know what you are doing please take this with a large grain of salt.

Can you disclose more detail?

Kind regards

	robert