V
Vincent Fourmond
Hello !
I have a rather tortured architecture where several classes should
share code for some class methods and for some instance methods. To fix
the ideas, I need that some class I define have:
def ThisClass.desc
return @desc
end
def desc
return self.class.desc
end
To do that, I define two modules
module BaseInclude
def desc
return self.class.desc
end
end
module BaseExtend
def desc
return @desc
end
end
and I include them with
class ThisClass
include BaseInclude
extend BaseExtend
end
That works perfectly fine. My question, then, is : is there a simpler
way ? I can't afford to have a shared ancestor for these classes.
Thanks !
Vince
I have a rather tortured architecture where several classes should
share code for some class methods and for some instance methods. To fix
the ideas, I need that some class I define have:
def ThisClass.desc
return @desc
end
def desc
return self.class.desc
end
To do that, I define two modules
module BaseInclude
def desc
return self.class.desc
end
end
module BaseExtend
def desc
return @desc
end
end
and I include them with
class ThisClass
include BaseInclude
extend BaseExtend
end
That works perfectly fine. My question, then, is : is there a simpler
way ? I can't afford to have a shared ancestor for these classes.
Thanks !
Vince