#include and #extend have same effect on instances as inheritance
Let's say we have this
module A; end
module B; end
class C; end
class D < C; end
Then we modify instance
d = D.new
D.send(:include, A)
d.extend(B)
d_meta = class << d; self; end
Lets see what we got (method dispatch lookup table)
d.class.ancestors
=> [D, A, C, Object, Kernel, BasicObject]
d_meta.ancestors
=> [B, D, A, C, Object, Kernel, BasicObject]
So it's all up to how and what structure you see
and to me, benefits of composition over inheritance is that it doesn't modify object dispatch hierarchy.
PS: pls comment here.
Interesting, thanks for this gist.
Does d_meta contain B as an ancestor because it's including d's singleton class in the lookup hierarchy?