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?
Thanks,
T.