module A; end
module B; end
class C; end
class D < C; end
d = D.new
D.send(:include, A)
d.extend(B)
d_meta = class << d; self; end
d.class.ancestors
=> [D, A, C, Object, Kernel, BasicObject]
d_meta.ancestors
=> [B, D, A, C, Object, Kernel, BasicObject]
and to me, benefits of composition over inheritance is that it doesn't modify object dispatch hierarchy.
PS: pls comment here.
I'm curious why you're drawn to these fallacies around extend/include at runtime. Have you been bitten by this before in the past? I often don't inherit from objects (like d_meta), but then maybe I don't do enough obscure programming :)