This is called the "Dyanmic Module Inclusion Problem". And Pit is
right, it is an implmentation issue. I think Matz would love to have a
fix for it, but appearently it is difficult, if not impossible, to do
so efficiently,
Thanks both of you for your insight. I've created a small hack to fix that issue
class Module
# Weird hack to ensure deep inclusion of modules
def include_deep(mod)
include mod
ancestors[1..-1].select do |a|
a != mod and not a.ancestors.include?(mod)
end.each { |a| a.include_deep(mod) }
end
end
Thanks both of you for your insight. I've created a small hack to fix that issue
class Module
# Weird hack to ensure deep inclusion of modules
def include_deep(mod)
include mod
ancestors[1..-1].select do |a|
a != mod and not a.ancestors.include?(mod)
end.each { |a| a.include_deep(mod) }
end
end
Hmm... Doesn't seem to do anything. Notice even without the above one
can instantiate a class and the mothod will "magically" showup. From
your example:
On 20/06/06, transfire@gmail.com <transfire@gmail.com> wrote:
Hmm... Doesn't seem to do anything. Notice even without the above one
can instantiate a class and the mothod will "magically" showup. From
your example:
doh' I would need to find the children and not the ancestors [C] of
the module (B) in which in include the other (A)... I guess it's
doable by browsing the ObjectSpace but it's quite expensive. If only
modules and classes would also list their childrens. Which is also
doable by overriding Module#included I guess but it's not really
reliable isn't it ?
···
On 20/06/06, Jonas Pfenniger <zimba.tm@gmail.com> wrote:
On 20/06/06, transfire@gmail.com <transfire@gmail.com> wrote:
> Hmm... Doesn't seem to do anything. Notice even without the above one
> can instantiate a class and the mothod will "magically" showup. From
> your example: